[]
Windows File Helper.
public static class NativeFile
Checks if the specified file path exists.
public static bool Exists(string filePath)
filePath
stringThe file path.
true
if the specified file path exists, false
otherwise
Gets the last write time access for the specified path.
public static DateTime GetLastWriteTime(string path)
path
stringThe path.
The last write time access
Opens a binary file, reads the contents of the file into a byte array, and then closes the file.
public static byte[] ReadAllBytes(string path)
path
stringThe file to open for reading.
A byte array containing the contents of the file.
Opens a text file, reads all lines of the file, and then closes the file.
public static string ReadAllText(string path, Encoding encoding, NativeFileShare sharing = NativeFileShare.Read)
path
stringThe file to open for reading.
encoding
System.Text.EncodingThe encoding.
sharing
NativeFileShareThe sharing.
A string containing all lines of the file.
Opens a text file, reads all lines of the file, and then closes the file.
public static string ReadAllText(string path)
path
stringThe file to open for reading.
A string containing all lines of the file.