A. File operations: For relatively simple data saving I. Read and write files:1. Create a file stream2. Creating a reader/writer3. Read and write Files4. Turn off reader/ writer5. close file Stream Ii. FileStream (file stream), which is mainly used to read and write data in a file, when creating a file stream, you need to specify the path of the action file, how the file is opened and how the file is accessed1. Syntax: FileStream File Object =NewFileStream (String filepath,filemode); A. FileMode: Open File Mode i. File Reader1. StreamWriter Writer: Primarily used to write data to a file stream a. Syntax: StreamWriter object name=NewStreamWriter (File stream object); B. Method: I. Write (): for writing to stream Ii. WriteLine (): Used to write a row of data III. Close (): Used to close the writer2. StreamReader reader: Primarily used to read data in a file stream a. Syntax: StreamReader object name=NewStreamReader (File stream object, encoding Class); I. Encoding class: Specifying character encoding1. UTF8: Get utf-8encoding of the format2. Default: Gets the current encoding of the operating system II. DriveInfo (disk): Disk details used to obtain registration for the local machine system III. Directory: is a static class that provides a number of static methods for manipulating directories and subdirectories, which can be used to create, move, complicate, and delete directories and subdirectories IV. DirectoryInfo: Not a static class that represents a physical directory on a drive v. file: is a static class that provides many static methods for working with files, such as copying, moving, renaming, creating, opening, and deleting file VI. FileInfo: Not a static class, FileInfo object represents a physical file for a disk or network location
C # language-07. File Operations