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.

Framework Classes ❘ 823<br />

File<br />

The File class provides static methods for working with files. The following table summarizes its<br />

most useful static methods.<br />

Method<br />

AppendAllText<br />

AppendText<br />

Copy<br />

Create<br />

CreateText<br />

Delete<br />

Exists<br />

GetAttributes<br />

GetCreationTime<br />

GetCreationTimeUtc<br />

GetLastAccessTime<br />

GetLastAccessTimeUtc<br />

GetLastWriteTime<br />

GetLastWriteTimeUtc<br />

Move<br />

Open<br />

OpenRead<br />

Purpose<br />

Adds text to the end of a file, creating the file if it doesn’t<br />

exist, and then closes the file.<br />

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

returns a StreamWriter attached to it.<br />

Copies a file.<br />

Creates a new file and returns a FileStream attached to it.<br />

Creates or opens a file for writing UTF-8 encoded text and<br />

returns a StreamWriter attached to it.<br />

Permanently deletes a file.<br />

Returns true if the specified file exists.<br />

Gets 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 />

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

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

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

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

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

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

Moves a file to a new location.<br />

Opens a file and returns a FileStream attached to it.<br />

Parameters let you specify the mode (Append, Create,<br />

CreateNew, Open, OpenOrCreate, or Truncate), access<br />

(Read, Write, or ReadWrite), and sharing (Read, Write,<br />

ReadWrite, or None) settings.<br />

Opens a file for reading and returns a FileStream<br />

attached to it.<br />

continues<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!