File and Streams There are many ways of organizing records in a file. There are many ways of organizing records in a file. The most common type of organization.

Slides:



Advertisements
Similar presentations
Reading and Writing Text Files Svetlin Nakov Telerik Corporation
Advertisements

Pemrograman VisualMinggu …12… Page 1 MINGGU Ke Duabelas Pemrograman Visual Pokok Bahasan: File and Stream Tujuan Instruksional Khusus: Mahasiswa dapat.
C# - Files and Streams Outline Files and Streams Classes File and Directory Creating a Sequential-Access File Reading Data from a Sequential-Access.
Files Files are used to store long term data. –Typically referred to as persistent data. –A file is a group of related records. –A list of friends addresses.
Files & Streams. Files Introduction Files are used for long-term retention of large amounts of data, even after the program that created the data terminates.
File Systems Files and directories Absolute and relative names Text and binary files Sequential-access and random-access files.
C# Programming: From Problem Analysis to Program Design1 Working with Files C# Programming: From Problem Analysis to Program Design 3 rd Edition 13.
13.1 Understanding Files The File class Objects can read and write to the file system Use the File class to hold information about files and directories.
MIS316 – BUSINESS APPLICATION DEVELOPMENT – Chapter 14 – Files and Streams 1Microsoft Visual C# 2012, Fifth Edition.
2. I/O Text Files CCSA225 - Advanced Java Programming Sarah Alodan
Understanding Input/Output (I/O) Classes Lesson 5.
Lecture Set 12 Sequential Files and Structures Part B – Reading and Writing Sequential Files.
Directory and File. Access Files in a Directory Name space: System.IO The Directory and File classes contain only shared methods that set or return information.
Visual C Sharp – File I/O - 1 Variables and arrays only temporary - lost when a program terminates Files used for long term storage (Data bases considered.
Chapter 12 Working with Files CIS 3260 Introduction to Programming using C# Hiro Takeda.
Neal Stublen Open/Close Connections  ADO.NET uses “connection pooling” to optimize opening and closing connections to the database.
Files and Streams. Java I/O File I/O I/O streams provide data input/output solutions to the programs. A stream can represent many different kinds of sources.
CIS 270—Application Development II Chapter 14—Files and Streams.
File I/O Applied Component-Based Software Engineering File I/O CSE 668 / ECE 668 Prof. Roger Crawfis.
Lector: Aliyev H.U. Lecture №5 Telecommunication network software design with.NET. Using streams for network programming TASHKENT UNIVERSITY OF INFORMATION.
Chapter 8 Data File Basics.
 2006 Pearson Education, Inc. All rights reserved Files and Streams.
1 14/10/58Dr.Mud-Armeen Munlin 1 Files and Streams ผศ. ดร. หมัดอามีน หมันหลิน Faculty of IST, MUT
SE-1020 Dr. Mark L. Hornick 1 File Input and Output.
Files and Streams File Types, Using Streams, Manipulating Files SoftUni Team Technical Trainers Software University
Chapter Ten Structures and Sequential Access Files Programming with Microsoft Visual Basic th Edition.
Reference: Lecturer Lecturer Reham O. Al-Abdul Jabba lectures for cap211 Files and Streams- I.
1 COMP3100e Developing Microsoft.Net Applications for Windows (Visual Basic.Net) Class 6 COMP3100E.
File I/O What We’ll Cover –Visual Basic Techniques for Text Files –.NET Techniques for Text Files What We’ll Not Cover –Binary File I/O –XML File I/O.
Files and Streams. Objectives Learn about the classes that support file input/output Understand the concept of abstraction and how it related to the file.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
CS360 Windows Programming
Chapter 14: Files and Streams. 2Microsoft Visual C# 2012, Fifth Edition Files and the File and Directory Classes Temporary storage – Usually called computer.
Using Text Files in Excel File I/O Methods. Working With Text Files A file can be accessed in any of three ways: –Sequential access: By far the most common.
BIM313 – Advanced Programming File Operations 1. Contents Structure of a File Reading/Writing Texts from/to Files File and Directory Operations 2.
CSCI 3328 Object Oriented Programming in C# Chapter 11: Files and Streams -- Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,
Input and Output 23: Input and Output
CSC 298 Streams and files.
Ajay Tripathi Input Output. Ajay Tripathi Input/output (IO) refers to the operations for reading and writing data to streams and files. In the.NET Framework,
CSCI 3328 Object Oriented Programming in C# Chapter 11: Files and Streams 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
 2007 Pearson Education, Inc. All rights reserved. 1 C File Processing.
Files and Streams. What is a file? Up until now, any stored data within a program is lost when the program closes. A file is a permanent way to store.
Files and Streams. Objectives Learn about the classes that support file input/output Understand the concept of abstraction and how it related to the file.
 2007 Pearson Education, Inc. All rights reserved C File Processing.
Files and Streams Lec Introduction  Files are used for long-term retention of large amounts of data, even after the program that created the.
Directory and File. Access Files in a Directory Name space: System.IO The Directory and File classes contain only shared methods that set or return information.
Input Output Eriq Muhammad Adams J |
Chapter 6: Creating Windows–based Applications 1 Microsoft® Visual C# 2008.
Object Based Programming Chapter 8. 2 Contrast ____________________ Languages –Action oriented –Concentrate on writing ________________ –Data supports.
Sequential files creation & writing
Input and Output 23: Input and Output
C# Programming: From Problem Analysis to Program Design
18 Files and Streams.
Defiana Arnaldy, M.Si File and Stream I/O Defiana Arnaldy, M.Si
How to work with files and data streams
CSCI 3327 Visual Basic Chapter 11: Files and Streams
Files and Streams.
Files and Streams Lect3 CT1411.
File Input/Output (I/O)
טיפול בקבצים ליווי מקצועי : ארז קלר
Today’s Lecture I/O Streams Tools for File I/O
Files & Streams.
The University of Texas – Pan American
CSCI 3328 Object Oriented Programming in C# Chapter 11: Files and Streams -- Exercises UTPA – Fall 2012 This set of slides is revised from lecture slides.
Files and Streams Lect10 GC201 12/1/2015.
CIS16 Application Development and Programming using Visual Basic.net
How to work with files and data streams
CSCI 3328 Object Oriented Programming in C# Chapter 11: Files and Streams UTPA – Fall 2012 This set of slides is revised from lecture slides of Prof.
Introduction to Programming Lecture 6
Files and Streams.
Presentation transcript:

File and Streams There are many ways of organizing records in a file. There are many ways of organizing records in a file. The most common type of organization is called a sequential file. The most common type of organization is called a sequential file..net framework views each file as a sequential stream of bytes.net framework views each file as a sequential stream of bytes Each file ends with either an end-of- file marker or at a specific byte number Each file ends with either an end-of- file marker or at a specific byte number

Class stream Abstract class Stream (namespace System::IO) provides functionality for representing streams as bytes Abstract class Stream (namespace System::IO) provides functionality for representing streams as bytes Class FileStream, MemoryStream and BufferedStream inherit from class Stream Class FileStream, MemoryStream and BufferedStream inherit from class Stream FileStream: read from and write data to sequential- access and random-access file FileStream: read from and write data to sequential- access and random-access file MemoryStream: enables transfers of data directly to and from memory (faster) MemoryStream: enables transfers of data directly to and from memory (faster) BufferedStream: use buffering to transfer data to or from a stream. (performance enhancement technique, in which each I/O operation is directed to a region in memory, called a buffer. The actual transfer is performed in one large physical output operation each time the buffer fills BufferedStream: use buffering to transfer data to or from a stream. (performance enhancement technique, in which each I/O operation is directed to a region in memory, called a buffer. The actual transfer is performed in one large physical output operation each time the buffer fills

Class File Class File is provided for maintaining files Class File is provided for maintaining files Class File cannot read from or write to files directly Class File cannot read from or write to files directly Separator character /. In.net, both / and \ are valid Separator character /. In.net, both / and \ are valid However, when use \ in string, one must use \\ However, when use \ in string, one must use \\ For example, C:\\CS603/project For example, C:\\CS603/project

Static methods Class File contain only static methods Class File contain only static methods You cannot instantiate objects of type File You cannot instantiate objects of type File Copy: copies a file to a new file Copy: copies a file to a new file Create: creates a file and return its associated FileStream Create: creates a file and return its associated FileStream Delete: deletes the specified file Delete: deletes the specified file Exists: return true if the specified file exists; otherwise, it returns false Exists: return true if the specified file exists; otherwise, it returns false GetCreationTime: return DateTime object representing the time that file was created GetCreationTime: return DateTime object representing the time that file was created GetLastAccessTime: GetLastAccessTime: GetLastWriteTime: GetLastWriteTime: Move: moves the specified file to a specified location Move: moves the specified file to a specified location

Static methods- continued Open: return FileStream associated with the specified file Open: return FileStream associated with the specified file OpenRead: returns a read-only FileStream associated with the specified file OpenRead: returns a read-only FileStream associated with the specified file OpenWrite: return a read/write FileStream associated with the specified file OpenWrite: return a read/write FileStream associated with the specified file OpenText: returns a StreamReader associated with the specified file OpenText: returns a StreamReader associated with the specified file

Class Directory Class Directory is provided for manipulating directories. Class Directory is provided for manipulating directories. It provides capabilities for manipulating and iteration directories It provides capabilities for manipulating and iteration directories Static methods Static methods CreateDirectory: creates a directory and returns its associated DirectoryInfo. CreateDirectory: creates a directory and returns its associated DirectoryInfo. The DirectoryInfo object returned by method CreateDirectory contains information about a directory. The DirectoryInfo object returned by method CreateDirectory contains information about a directory.

Other static methods Delete: deletes the specified directory Delete: deletes the specified directory Exists: return true if the specified directory exists; otherwise, it returns false Exists: return true if the specified directory exists; otherwise, it returns false GetLastWriteTime: return a DataTime object representing the time that the directory was last modified GetLastWriteTime: return a DataTime object representing the time that the directory was last modified GetDirectories: return a String *array representing the names of the directories in the specified directory GetDirectories: return a String *array representing the names of the directories in the specified directory GetFiles: returns a String * array representing the names of the files in the specified directory GetFiles: returns a String * array representing the names of the files in the specified directory GetCreationTime GetCreationTime