File

File class

Provides methods for manipulating files. This is a static type with no instance services. You should never create instances of it by any means.

class File

Methods

MethodDescription
static void AppendAllLines(const String&, const SharedPtr<Collections::Generic::IEnumerable<String>>&, const EncodingPtr&)Appends strings from the specified collection of strings to the specified file using the specified encoding by writing each string in a new line. If the specified file does not exist, it is created. The file is closed after writing all strings.
static void AppendAllText(const String&, const String&, const EncodingPtr&)Appends the specified string to the specified file using the specified encoding.
static StreamWriterPtr AppendText(const String&)Creates a StreamWriter object that appends text to the specified file using UTF-8 encoding. If the specified file does not exist, it is created.
static void Copy(const String&, const String&, bool)Copies the specified file to the specified location. If the destination file already exists, a parameter specifies if it should be overwritten.
static FileStreamPtr Create(const String&, int32_t, FileOptions)Creates a new file (or overwrites existing) and opens it for reading and writing access using the specified buffer size and options.
static StreamWriterPtr CreateText(const String&)Creates a new or opens existing file for writing UTF-8 encoded text.
static void Decrypt(const String&)NOT IMPLEMENTED.
static void Delete(const String&)Deletes the specified file or directory.
static void Encrypt(const String&)NOT IMPLEMENTED.
static bool Exists(const String&)Determines if the specified path references an existing file.
static FileAttributes GetAttributes(const String&)Returns the attributes of the specified entity.
static DateTime GetCreationTime(const String&)Returns the creation time of the specified entity as local time.
static DateTime GetCreationTimeUtc(const String&)Returns the creation time of the specified entity as UTC time.
static DateTime GetLastAccessTime(const String&)Returns the last access time of the specified entity as local time.
static DateTime GetLastAccessTimeUtc(const String&)Returns the last access time of the specified entity as UTC time.
static DateTime GetLastWriteTime(const String&)Returns the last write time of the specified entity as local time.
static DateTime GetLastWriteTimeUtc(const String&)Returns the last write time of the specified entity as UTC time.
static void Move(const String&, const String&)Moves the specified file to the new location.
static FileStreamPtr Open(const String&, FileMode)Opens the specified file in the specified mode for reading and writing and with no sharing.
static FileStreamPtr Open(const String&, FileMode, FileAccess, FileShare)Opens the specified file in the specified mode, with the specified access type and sharing option.
static FileStreamPtr OpenRead(const String&)Opens the specified file for reading only, in ‘Open’ mode with shared access for reading.
static StreamReaderPtr OpenText(const String&, const EncodingPtr&)Opens the specified existing file for reading text using UTF-8 encoding with no sharing.
static FileStreamPtr OpenWrite(const String&)Opens the specified file for writing only, in ‘OpenOrCreate’ mode with no sharing.
static ArrayPtr<uint8_t> ReadAllBytes(const String&)Reads the content of the specified binary file to a byte array.
static ArrayPtr<String> ReadAllLines(const String&, const EncodingPtr&)Reads the content of the specified text file line by line to an array of strings using the specified character encoding.
static String ReadAllText(const String&, const EncodingPtr&)Reads the content of the specified text file to a single String object using the specified character encoding.
static SharedPtr<Collections::Generic::IEnumerable<String>> ReadLines(const String&, const EncodingPtr&)Reads the content of the specified text file line by line using the specified character encoding and returns enumerable collection of strings each of which represents a single line of the file’s content.
static void Replace(const String&, const String&, const String&, bool)Replaces the contents of a one file with another and creates a backup of the replaced file.
static void SetAttributes(const String&, FileAttributes)Sets the specified attributes on the specified file.
static void SetCreationTime(const String&, DateTime)NOT IMPLEMENTED.
static void SetCreationTimeUtc(const String&, DateTime)NOT IMPLEMENTED.
static void SetLastAccessTime(const String&, DateTime)NOT IMPLEMENTED.
static void SetLastAccessTimeUtc(const String&, DateTime)NOT IMPLEMENTED.
static void SetLastWriteTime(const String&, DateTime)Sets the last write time of the specified entity as local time.
static void SetLastWriteTimeUtc(const String&, DateTime)Sets the last write time of the specified entity as UTC time.
static void WriteAllBytes(const String&, const ArrayPtr<uint8_t>&)Overwrites the specified binary file and writes the specified bytes to it.
static void WriteAllLines(const String&, const SharedPtr<Collections::Generic::IEnumerable<String>>&, const EncodingPtr&)Creates a new text file or overwrites the existing one and writes all strings from the specified enumerable collection of strings to it, each string on a new line, using the specified encoding.
static void WriteAllLines(const String&, const ArrayPtr<String>&, const EncodingPtr&)Creates a new text file or overwrites the existing one and writes all strings from the specified array of strings to it, each string on a new line, using the specified encoding.
static void WriteAllText(const String&, const String&, const EncodingPtr&)Creates a new text file or overwrites the existing one and writes the content of the specified string to it using the specified encoding.

Fields

FieldDescription
static DefaultBufferSizeDefault value of the number of bytes buffered during reading from and writing to a file.

See Also