Click or drag to resize
File Class
Provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of FileStream objects.
Inheritance Hierarchy
SystemObject
  System.IOFile

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static class File

The File type exposes the following members.

Methods
  NameDescription
Public methodStatic memberAppendText
Creates a StreamWriter that appends UTF-8 encoded text to an existing file.
Public methodStatic memberCopy(String, String)
Copies an existing file to a new file. Overwriting a file of the same name is not allowed.
Public methodStatic memberCopy(String, String, Boolean)
Copies an existing file to a new file. Overwriting a file of the same name is allowed.
Public methodStatic memberCreate(String)
Creates or overwrites a file in the specified path.
Public methodStatic memberCreate(String, Int32)
Creates or overwrites the specified file.
Public methodStatic memberCreate(String, Int32, FileOptions)
Creates or overwrites the specified file, specifying a buffer size and a FileOptions value that describes how to create or overwrite the file.
Public methodStatic memberCreate(String, Int32, FileOptions, FileSecurity)
Creates or overwrites the specified file with the specified buffer size, file options, and file security.
Public methodStatic memberCreateText
Creates or opens a file for writing UTF-8 encoded text.
Public methodStatic memberDelete
Deletes the specified file.
Public methodStatic memberExists
Determines whether the specified file exists.
Public methodStatic memberOpen(String, FileMode)
Opens a FileStream on the specified path with read/write access.
Public methodStatic memberOpen(String, FileMode, FileAccess)
Opens a FileStream on the specified path, with the specified mode and access.
Public methodStatic memberOpen(String, FileMode, FileAccess, FileShare)
Opens a FileStream on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option.
Public methodStatic memberOpenRead
Opens an existing file for reading.
Public methodStatic memberOpenWrite
Opens an existing file or creates a new file for writing.
Public methodStatic memberReadAllBytes
Opens a binary file, reads the contents of the file into a byte array, and then closes the file.
Public methodStatic memberReadAllText(String)
Opens a text file, reads all lines of the file, and then closes the file.
Public methodStatic memberReadAllText(String, Encoding)
Opens a file, reads all lines of the file with the specified encoding, and then closes the file.
Top
See Also