C # language-07. File Operations

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.