Skip to Content
Beginning C# 3.0
book

Beginning C# 3.0

by Jack Purdum
May 2008
Beginner
550 pages
13h 22m
English
Wrox
Content preview from Beginning C# 3.0

13.2. File Namespace

The File namespace presents you with a number of useful methods that you will want to use in your programs. A partial list of the methods in the File namespace is presented in Table 13-4.

Table 13-4. Table 13-4
MethodDescription
AppendAllText()Appends a string of text to a specified file. The method is overloaded so that different encoding schemes may be used.
AppendText()Uses a StreamWriter object to append UTF-8-encoded text to a specified file. UTF-8 is an eight-bit Unicode Transformation Format that is backward-compatible with the ASCII character set.
Copy()Copies a specified file.
Create()Creates a specified file.
CreateText()Creates or opens a file for UTF-8 encoded text
Delete()Deletes a specified file.
Exists()Checks to see if a specified file exists.
GetCreationTime()Returns the date and time a file was created.
Move()Moves a specified file to a specified location.
Open()Uses a FileStream object to open a specified file.
OpenRead()Opens an existing file for reading.
OpenText()Opens a UTF-8 file for reading.
OpenWrite()Opens an existing file for writing.
ReadAllBytes()Opens a binary file and copies the contents into a byte array. (Each ReadAll*() method has a corresponding WriteAll*() method.)
ReadAllLines()Opens a text file, reads all lines in the file into a string array, and closes it.
ReadAllText()Opens a text file, reads the contents into a string, and closes it.
Replace()Replaces the content of one file with that of another file, deleting the original file and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Navigating the Metaverse

Navigating the Metaverse

Cathy Hackl, Dirk Lueth, Tommaso Di Bartolo, John Arkontaky, Yat Siu
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
Capitalism at Risk

Capitalism at Risk

Joseph L. Bower, Herman B. Leonard, Lynn S. Paine

Publisher Resources

ISBN: 9780470261293Purchase book