Input/Output - All What Need To Know About .NET 0
- File System
- Reading and Writing Files and Streams
File System
The System.IO namespace provides classes for enumerating drives, managing files and folders, and responding to changes in the file system.
Use the DriveInfo.GetDrives static method to retrieve an array of DriveInfo objects that describe the drives attached to the computer.
The File class provides static methods for copying, moving, and deleting folders and files. You can also create instances of the FileInfo and DirectoryInfo classes.
Use the FileSystemWatcher class to respond to changes in the file system, such as new or changed files.
Reading and Writing Files and Streams
Streams provide a flexible way to store data to files or memory. Using different types of streams, you can compress data or store it to isolated storage.
Use the TextReader and TextWriter, BinaryReader and BinaryWriter, and StringReader and StringWriter classes to read and write text files, binary files, and strings (respectively) as streams.
Use the MemoryStream class to store a stream in memory. You can then call MemoryStream.WriteTo to save the stream to a file on the disk.
Use the GZipStream and DeflateStream classes to read and write compressed data.
Isolated storage, implemented in the System.IO.IsolatedStorage namespace, allows you to save files in a part of the file system that is managed by the .NET Framework.