Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Common I/O Tasks


The System.IO namespace provides several classes that allow for various actions, such as reading and writing, to be performed on files, directories, and streams. For more information, see File and Stream I-O.

To do this...See the example in this topic...
Create a text fileFile.CreateText method

 FileInfo.CreateText method

 File.Create method

 FileInfo.Create method
Write to a text fileHow to: Write Text to a File

 How to: Write a Text File (C++/CLI)
Read from a text fileHow to: Read Text from a File
Append text to a fileHow to: Open and Append to a Log File

 File.AppendText method

 FileInfo.AppendText method
Rename or move a fileFile.Move method

 FileInfo.MoveTo method
Delete a fileFile.Delete method

 FileInfo.Delete method
Copy a fileFile.Copy method

 FileInfo.CopyTo method
Get the size of a fileFileInfo.Length property
Get the attributes of a fileFile.GetAttributes method
Set the attributes of a fileFile.SetAttributes method
Determine whether a file existsFile.Exists method
Read from a binary fileHow to: Read and Write to a Newly Created Data File
Write to a binary fileHow to: Read and Write to a Newly Created Data File
Retrieve a file name extensionPath.GetExtension method
Retrieve the fully qualified path of a filePath.GetFullPath method
Retrieve the file name and extension from a pathPath.GetFileName method
Change the extension of a filePath.ChangeExtension method
To do this...See the example in this topic...
Access a file in a special folder such as My DocumentsHow to: Write Text to a File
Create a directoryDirectory.CreateDirectory method

 FileInfo.Directory property
Create a subdirectoryDirectoryInfo.CreateSubdirectory method
Rename or move a directoryDirectory.Move method

 DirectoryInfo.MoveTo method
Copy a directoryHow to: Copy Directories
Delete a directoryDirectory.Delete method

 DirectoryInfo.Delete method
See the files and subdirectories in a directoryHow to: Enumerate Directories and Files
Find the size of a directorySystem.IO.Directory class
Determine whether a directory existsDirectory.Exists method

File and Stream I-O
Composing Streams
Asynchronous File I/O

© 2017 Microsoft