03.01.2015 Views

C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

824 ❘ Appendix S Filesystem Classes<br />

(continued)<br />

Method<br />

OpenText<br />

OpenWrite<br />

ReadAllBytes<br />

ReadAllLines<br />

ReadAllText<br />

Replace<br />

SetAttributes<br />

SetCreationTime<br />

SetCreationTimeUtc<br />

SetLastAccessTime<br />

SetLastAccessTimeUtc<br />

SetLastWriteTime<br />

SetLastWriteTimeUtc<br />

WriteAllBytes<br />

WriteAllLines<br />

WriteAllText<br />

Purpose<br />

Opens a UTF-8 encoded text file for reading and returns a<br />

StreamReader attached to it.<br />

Opens a file for writing and returns a FileStream attached<br />

to it.<br />

Returns a file’s contents in an array of bytes.<br />

Returns a file’s lines in an array of strings.<br />

Returns a file’s contents in a string.<br />

This method takes three file paths as parameters representing<br />

a source file, a destination file, and a backup file.<br />

If the backup file exists, the method permanently deletes<br />

it. It then moves the destination file to the backup file and<br />

moves the source file to the destination file. This method<br />

throws an exception if either the source file or the destination<br />

file doesn’t exist.<br />

Sets a file’s attributes. This is a combination of flags defined<br />

by the FileAttributes enumeration, which defines the values<br />

Archive, Compressed, Device, Directory, Encrypted,<br />

Hidden, Normal, NotContextIndexed, Offline, ReadOnly,<br />

ReparsePoint, SparseFile, System, and Temporary.<br />

Sets a file’s creation date and time.<br />

Sets a file’s creation date and time in UTC.<br />

Sets a file’s last access date and time.<br />

Sets a file’s last access date and time in UTC.<br />

Sets a file’s last write date and time.<br />

Sets a file’s last write date and time in UTC.<br />

Creates or overwrites a file, writes an array of bytes into it,<br />

and closes the file.<br />

Creates or overwrites a file, writes an array of strings into<br />

it, and closes the file.<br />

Creates or overwrites a file, writes a string into it, and<br />

closes the file.<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!