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.
Common File Tasks
To do this... | See the example in this topic... |
---|---|
Create a text file. |
|
Write to a text file. |
|
Read from a text file. |
|
Append text to a file. |
How to: Open and Append to a Log File |
Rename or move a file. |
|
Delete a file. |
|
Copy a file. |
|
Get the size of a file. |
|
Get the attributes of a file. |
|
Set the attributes of a file. |
System.IO.File.SetAttributes(System.String,System.IO.FileAttributes) |
Determine whether a file exists. |
|
Read from a binary file. |
|
Write to a binary file. |
|
Retrieve a file extension. |
|
Retrieve the fully qualified path of a file. |
|
Retrieve the file name and extension from a path. |
|
Change the extension of a file. |
Common Directory Tasks
To do this... | See the example in this topic... |
---|---|
Rename or move a directory. |
|
Delete a directory. |
|
Create a directory. |
|
Create a subdirectory. |
|
See the files in a directory. |
|
See the subdirectories of a directory. |
|
See all the files in all subdirectories of a directory. |
|
Find the size of a directory. |
|
Determine whether a directory exists. |
See Also
Concepts
Basic File I/O
Composing Streams
Asynchronous File I/O