C # various file operations

Source: Internet
Author: User

When I first learned C #, I felt that the language was so simple that I didn't have to spend time on it. But when I really started my first software, I feel that he hasn't understood many aspects yet. I think I should write down what I understand, share it with you, and record my progress.

Most operations on the file system are encapsulated in the system. Io namespace. Use the Directory class and file class to manage file directories and file operations, such as copying, cutting, deleting, and creating file directories and files; directoryinfo and fileinfo are corresponding instance operations. If you want to reuse an object multiple times, you can use directoryinfo,FileinfoInstead of directory, the corresponding static method of the file class. An important part of file operations is the reading and writing of files, which are implemented through "streams. Stream is the abstract base class of all streams. filestream and memorystream publish file-based streams, which support both synchronous read/write operations and asynchronous read/write operations. textreader and textwriter are streamreader, streamwriter, stringreader, and stringwriter abstract base classes. streamreader, streamwriter, stringreader, and stringwriter can read and write upper-layer files. It is worth mentioning that network operations can also be seen as operations on a file system in a broad sense. In the next article, I will summarize the relationships between classes used in network programming, I hope it will be helpful to you, and I hope you will correct the mistakes.

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.