January 2003
Intermediate to advanced
896 pages
19h 58m
English
The File class provides static members for creating, copying, moving, and deleting files. The FileInfo class provides the same features but as instance members of the class.
The Create static method of the File class creates or overwrites a file and returns a FileStream object. You can then read the file at the byte level using the returned FileStream, or you can read the file at the character level using a StreamReader. The following code creates a file called myFile.txt and then creates a StreamWriter object based on the FileStream object returned by the call to File.Create. If an error arises, such as the file already being open, an exception is thrown.
try { ...Read now
Unlock full access