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 file |
FileCreateText method FileInfoCreateText method FileCreate method FileInfoCreate method |
|
Write to a text file |
|
|
Read from a text file |
|
|
Append text to a file |
How to: Open and Append to a Log File FileAppendText method FileInfoAppendText method |
|
Rename or move a file |
FileMove method FileInfoMoveTo method |
|
Delete a file |
FileDelete method FileInfoDelete method |
|
Copy a file |
FileCopy method FileInfoCopyTo method |
|
Get the size of a file |
FileInfoLength property |
|
Get the attributes of a file |
FileGetAttributes method |
|
Set the attributes of a file |
FileSetAttributes method |
|
Determine whether a file exists |
FileExists method |
|
Read from a binary file |
|
|
Write to a binary file |
|
|
Retrieve a file name extension |
PathGetExtension method |
|
Retrieve the fully qualified path of a file |
PathGetFullPath method |
|
Retrieve the file name and extension from a path |
PathGetFileName method |
|
Change the extension of a file |
PathChangeExtension method |
|
To do this... |
See the example in this topic... |
|---|---|
|
Create a directory |
DirectoryCreateDirectory methodFileInfoDirectory property |
|
Create a subdirectory |
|
|
Rename or move a directory |
DirectoryMove method DirectoryInfoMoveTo method |
|
Copy a directory |
|
|
Delete a directory |
DirectoryDelete method DirectoryInfoDelete method |
|
See the files and subdirectories in a directory |
|
|
Find the size of a directory |
Directory class |
|
Determine whether a directory exists |
DirectoryExists method |