using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; namespace System.IO { /// Provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of objects. /// 1 // Token: 0x020001B2 RID: 434 [ComVisible(true)] public static class File { /// Opens a file, appends the specified string to the file, and then closes the file. If the file does not exist, this method creates a file, writes the specified string to the file, then closes the file. /// The file to append the specified string to. /// The string to append to the file. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file. /// /// specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. /// The file specified in was not found. /// /// is in an invalid format. /// The caller does not have the required permission. /// 1 /// /// /// // Token: 0x06001636 RID: 5686 RVA: 0x00055628 File Offset: 0x00053828 public static void AppendAllText(string path, string contents) { using (TextWriter textWriter = new StreamWriter(path, true)) { textWriter.Write(contents); } } /// Appends the specified string to the file, creating the file if it does not already exist. /// The file to append the specified string to. /// The string to append to the file. /// The character encoding to use. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file. /// /// specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. /// The file specified in was not found. /// /// is in an invalid format. /// The caller does not have the required permission. /// 1 /// /// /// // Token: 0x06001637 RID: 5687 RVA: 0x00055674 File Offset: 0x00053874 public static void AppendAllText(string path, string contents, Encoding encoding) { using (TextWriter textWriter = new StreamWriter(path, true, encoding)) { textWriter.Write(contents); } } /// Creates a that appends UTF-8 encoded text to an existing file. /// A StreamWriter that appends UTF-8 encoded text to an existing file. /// The path to the file to append to. /// The caller does not have the required permission.-OR- is read-only. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x06001638 RID: 5688 RVA: 0x000556C0 File Offset: 0x000538C0 public static StreamWriter AppendText(string path) { return new StreamWriter(path, true); } /// Copies an existing file to a new file. Overwriting a file of the same name is not allowed. /// The file to copy. /// The name of the destination file. This cannot be a directory or an existing file. /// The caller does not have the required permission. /// /// or is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .-or- or specifies a directory. /// /// or is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The path specified in or is invalid (for example, it is on an unmapped drive). /// /// was not found. /// /// exists.-or- An I/O error has occurred. /// /// or is in an invalid format. /// 1 /// /// /// // Token: 0x06001639 RID: 5689 RVA: 0x000556CC File Offset: 0x000538CC public static void Copy(string sourceFileName, string destFileName) { File.Copy(sourceFileName, destFileName, false); } /// Copies an existing file to a new file. Overwriting a file of the same name is allowed. /// The file to copy. /// The name of the destination file. This cannot be a directory. /// true if the destination file can be overwritten; otherwise, false. /// The caller does not have the required permission. -or- is read-only. /// /// or is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .-or- or specifies a directory. /// /// or is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The path specified in or is invalid (for example, it is on an unmapped drive). /// /// was not found. /// /// exists and is false.-or- An I/O error has occurred. /// /// or is in an invalid format. /// 1 /// /// /// // Token: 0x0600163A RID: 5690 RVA: 0x000556D8 File Offset: 0x000538D8 public static void Copy(string sourceFileName, string destFileName, bool overwrite) { if (sourceFileName == null) { throw new ArgumentNullException("sourceFileName"); } if (destFileName == null) { throw new ArgumentNullException("destFileName"); } if (sourceFileName.Length == 0) { throw new ArgumentException("An empty file name is not valid.", "sourceFileName"); } if (sourceFileName.Trim().Length == 0 || sourceFileName.IndexOfAny(Path.InvalidPathChars) != -1) { throw new ArgumentException("The file name is not valid."); } if (destFileName.Length == 0) { throw new ArgumentException("An empty file name is not valid.", "destFileName"); } if (destFileName.Trim().Length == 0 || destFileName.IndexOfAny(Path.InvalidPathChars) != -1) { throw new ArgumentException("The file name is not valid."); } MonoIOError monoIOError; if (!MonoIO.Exists(sourceFileName, out monoIOError)) { throw new FileNotFoundException(Locale.GetText("{0} does not exist", new object[] { sourceFileName }), sourceFileName); } if ((File.GetAttributes(sourceFileName) & FileAttributes.Directory) == FileAttributes.Directory) { throw new ArgumentException(Locale.GetText("{0} is a directory", new object[] { sourceFileName })); } if (MonoIO.Exists(destFileName, out monoIOError)) { if ((File.GetAttributes(destFileName) & FileAttributes.Directory) == FileAttributes.Directory) { throw new ArgumentException(Locale.GetText("{0} is a directory", new object[] { destFileName })); } if (!overwrite) { throw new IOException(Locale.GetText("{0} already exists", new object[] { destFileName })); } } string directoryName = Path.GetDirectoryName(destFileName); if (directoryName != string.Empty && !Directory.Exists(directoryName)) { throw new DirectoryNotFoundException(Locale.GetText("Destination directory not found: {0}", new object[] { directoryName })); } if (!MonoIO.CopyFile(sourceFileName, destFileName, overwrite, out monoIOError)) { string text = Locale.GetText("{0}\" or \"{1}", new object[] { sourceFileName, destFileName }); throw MonoIO.GetException(text, monoIOError); } } /// Creates or overwrites a file in the specified path. /// A that provides read/write access to the file specified in . /// The path and name of the file to create. /// The caller does not have the required permission.-or- specified a file that is read-only. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// An I/O error occurred while creating the file. /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x0600163B RID: 5691 RVA: 0x000558AC File Offset: 0x00053AAC public static FileStream Create(string path) { return File.Create(path, 8192); } /// Creates or overwrites the specified file. /// A with the specified buffer size that provides read/write access to the file specified in . /// The name of the file. /// The number of bytes buffered for reads and writes to the file. /// The caller does not have the required permission.-or- specified a file that is read-only. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// An I/O error occurred while creating the file. /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x0600163C RID: 5692 RVA: 0x000558BC File Offset: 0x00053ABC public static FileStream Create(string path, int bufferSize) { return new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize); } /// Creates or opens a file for writing UTF-8 encoded text. /// A that writes to the specified file using UTF-8 encoding. /// The file to be opened for writing. /// The caller does not have the required permission. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x0600163D RID: 5693 RVA: 0x000558C8 File Offset: 0x00053AC8 public static StreamWriter CreateText(string path) { return new StreamWriter(path, false); } /// Deletes the specified file. An exception is not thrown if the specified file does not exist. /// The name of the file to be deleted. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path is invalid, (for example, it is on an unmapped drive). /// The specified file is in use. /// /// is in an invalid format. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The caller does not have the required permission.-or- is a directory.-or- specified a read-only file. /// 1 /// /// /// // Token: 0x0600163E RID: 5694 RVA: 0x000558D4 File Offset: 0x00053AD4 public static void Delete(string path) { if (path == null) { throw new ArgumentNullException("path"); } if (path.Trim().Length == 0 || path.IndexOfAny(Path.InvalidPathChars) >= 0) { throw new ArgumentException("path"); } if (Directory.Exists(path)) { throw new UnauthorizedAccessException(Locale.GetText("{0} is a directory", new object[] { path })); } string directoryName = Path.GetDirectoryName(path); if (directoryName != string.Empty && !Directory.Exists(directoryName)) { throw new DirectoryNotFoundException(Locale.GetText("Could not find a part of the path \"{0}\".", new object[] { path })); } MonoIOError monoIOError; if (!MonoIO.DeleteFile(path, out monoIOError) && monoIOError != MonoIOError.ERROR_FILE_NOT_FOUND) { throw MonoIO.GetException(path, monoIOError); } } /// Determines whether the specified file exists. /// true if the caller has the required permissions and contains the name of an existing file; otherwise, false. This method also returns false if is null, an invalid path, or a zero-length string. If the caller does not have sufficient permissions to read the specified file, no exception is thrown and the method returns false regardless of the existence of . /// The file to check. /// 1 /// /// /// // Token: 0x0600163F RID: 5695 RVA: 0x0005599C File Offset: 0x00053B9C public static bool Exists(string path) { MonoIOError monoIOError; return path != null && path.Trim().Length != 0 && path.IndexOfAny(Path.InvalidPathChars) < 0 && MonoIO.ExistsFile(path, out monoIOError); } /// Gets the of the file on the path. /// The of the file on the path. /// The path to the file. /// /// is empty, contains only white spaces, or contains invalid characters. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// /// is in an invalid format. /// /// represents a file and is invalid, such as being on an unmapped drive, or the file cannot be found. /// /// represents a directory and is invalid, such as being on an unmapped drive, or the directory cannot be found. /// This file is being used by another process. /// The caller does not have the required permission. /// 1 /// /// /// // Token: 0x06001640 RID: 5696 RVA: 0x000559DC File Offset: 0x00053BDC public static FileAttributes GetAttributes(string path) { if (path == null) { throw new ArgumentNullException("path"); } if (path.Trim().Length == 0) { throw new ArgumentException(Locale.GetText("Path is empty")); } if (path.IndexOfAny(Path.InvalidPathChars) >= 0) { throw new ArgumentException(Locale.GetText("Path contains invalid chars")); } MonoIOError monoIOError; FileAttributes fileAttributes = MonoIO.GetFileAttributes(path, out monoIOError); if (monoIOError != MonoIOError.ERROR_SUCCESS) { throw MonoIO.GetException(path, monoIOError); } return fileAttributes; } /// Returns the creation date and time of the specified file or directory. /// A structure set to the creation date and time for the specified file or directory. This value is expressed in local time. /// The file or directory for which to obtain creation date and time information. /// The caller does not have the required permission. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x06001641 RID: 5697 RVA: 0x00055A54 File Offset: 0x00053C54 public static DateTime GetCreationTime(string path) { File.CheckPathExceptions(path); MonoIOStat monoIOStat; MonoIOError monoIOError; if (MonoIO.GetFileStat(path, out monoIOStat, out monoIOError)) { return DateTime.FromFileTime(monoIOStat.CreationTime); } if (monoIOError == MonoIOError.ERROR_PATH_NOT_FOUND || monoIOError == MonoIOError.ERROR_FILE_NOT_FOUND) { return File.DefaultLocalFileTime; } throw new IOException(path); } /// Returns the creation date and time, in coordinated universal time (UTC), of the specified file or directory. /// A structure set to the creation date and time for the specified file or directory. This value is expressed in UTC time. /// The file or directory for which to obtain creation date and time information. /// The caller does not have the required permission. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// /// is in an invalid format. /// 2 /// /// /// // Token: 0x06001642 RID: 5698 RVA: 0x00055AA0 File Offset: 0x00053CA0 public static DateTime GetCreationTimeUtc(string path) { return File.GetCreationTime(path).ToUniversalTime(); } /// Returns the date and time the specified file or directory was last accessed. /// A structure set to the date and time that the specified file or directory was last accessed. This value is expressed in local time. /// The file or directory for which to obtain access date and time information. /// The caller does not have the required permission. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x06001643 RID: 5699 RVA: 0x00055ABC File Offset: 0x00053CBC public static DateTime GetLastAccessTime(string path) { File.CheckPathExceptions(path); MonoIOStat monoIOStat; MonoIOError monoIOError; if (MonoIO.GetFileStat(path, out monoIOStat, out monoIOError)) { return DateTime.FromFileTime(monoIOStat.LastAccessTime); } if (monoIOError == MonoIOError.ERROR_PATH_NOT_FOUND || monoIOError == MonoIOError.ERROR_FILE_NOT_FOUND) { return File.DefaultLocalFileTime; } throw new IOException(path); } /// Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last accessed. /// A structure set to the date and time that the specified file or directory was last accessed. This value is expressed in UTC time. /// The file or directory for which to obtain access date and time information. /// The caller does not have the required permission. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x06001644 RID: 5700 RVA: 0x00055B08 File Offset: 0x00053D08 public static DateTime GetLastAccessTimeUtc(string path) { return File.GetLastAccessTime(path).ToUniversalTime(); } /// Returns the date and time the specified file or directory was last written to. /// A structure set to the date and time that the specified file or directory was last written to. This value is expressed in local time. /// The file or directory for which to obtain write date and time information. /// The caller does not have the required permission. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x06001645 RID: 5701 RVA: 0x00055B24 File Offset: 0x00053D24 public static DateTime GetLastWriteTime(string path) { File.CheckPathExceptions(path); MonoIOStat monoIOStat; MonoIOError monoIOError; if (MonoIO.GetFileStat(path, out monoIOStat, out monoIOError)) { return DateTime.FromFileTime(monoIOStat.LastWriteTime); } if (monoIOError == MonoIOError.ERROR_PATH_NOT_FOUND || monoIOError == MonoIOError.ERROR_FILE_NOT_FOUND) { return File.DefaultLocalFileTime; } throw new IOException(path); } /// Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last written to. /// A structure set to the date and time that the specified file or directory was last written to. This value is expressed in UTC time. /// The file or directory for which to obtain write date and time information. /// The caller does not have the required permission. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// /// is in an invalid format. /// 2 /// /// /// // Token: 0x06001646 RID: 5702 RVA: 0x00055B70 File Offset: 0x00053D70 public static DateTime GetLastWriteTimeUtc(string path) { return File.GetLastWriteTime(path).ToUniversalTime(); } /// Moves a specified file to a new location, providing the option to specify a new file name. /// The name of the file to move. /// The new path for the file. /// The destination file already exists.-or- was not found. /// /// or is null. /// /// or is a zero-length string, contains only white space, or contains invalid characters as defined in . /// The caller does not have the required permission. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The path specified in or is invalid, (for example, it is on an unmapped drive). /// /// or is in an invalid format. /// 1 /// /// /// // Token: 0x06001647 RID: 5703 RVA: 0x00055B8C File Offset: 0x00053D8C public static void Move(string sourceFileName, string destFileName) { if (sourceFileName == null) { throw new ArgumentNullException("sourceFileName"); } if (destFileName == null) { throw new ArgumentNullException("destFileName"); } if (sourceFileName.Length == 0) { throw new ArgumentException("An empty file name is not valid.", "sourceFileName"); } if (sourceFileName.Trim().Length == 0 || sourceFileName.IndexOfAny(Path.InvalidPathChars) != -1) { throw new ArgumentException("The file name is not valid."); } if (destFileName.Length == 0) { throw new ArgumentException("An empty file name is not valid.", "destFileName"); } if (destFileName.Trim().Length == 0 || destFileName.IndexOfAny(Path.InvalidPathChars) != -1) { throw new ArgumentException("The file name is not valid."); } MonoIOError monoIOError; if (!MonoIO.Exists(sourceFileName, out monoIOError)) { throw new FileNotFoundException(Locale.GetText("{0} does not exist", new object[] { sourceFileName }), sourceFileName); } string directoryName = Path.GetDirectoryName(destFileName); if (directoryName != string.Empty && !Directory.Exists(directoryName)) { throw new DirectoryNotFoundException(Locale.GetText("Could not find a part of the path.")); } if (MonoIO.MoveFile(sourceFileName, destFileName, out monoIOError)) { return; } if (monoIOError == MonoIOError.ERROR_ALREADY_EXISTS) { throw MonoIO.GetException(monoIOError); } if (monoIOError == MonoIOError.ERROR_SHARING_VIOLATION) { throw MonoIO.GetException(sourceFileName, monoIOError); } throw MonoIO.GetException(monoIOError); } /// Opens a on the specified path with read/write access. /// A opened in the specified mode and path, with read/write access and not shared. /// The file to open. /// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid, (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file. /// /// specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. -or- is and the specified file is a hidden file. /// /// specified an invalid value. /// The file specified in was not found. /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x06001648 RID: 5704 RVA: 0x00055CDC File Offset: 0x00053EDC public static FileStream Open(string path, FileMode mode) { return new FileStream(path, mode, (mode != FileMode.Append) ? FileAccess.ReadWrite : FileAccess.Write, FileShare.None); } /// Opens a on the specified path, with the specified mode and access. /// An unshared that provides access to the specified file, with the specified mode and access. /// The file to open. /// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten. /// A value that specifies the operations that can be performed on the file. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .-or- specified Read and specified Create, CreateNew, Truncate, or Append. /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid, (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file. /// /// specified a file that is read-only and is not Read.-or- specified a directory.-or- The caller does not have the required permission. -or- is and the specified file is a hidden file. /// /// or specified an invalid value. /// The file specified in was not found. /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x06001649 RID: 5705 RVA: 0x00055CF4 File Offset: 0x00053EF4 public static FileStream Open(string path, FileMode mode, FileAccess access) { return new FileStream(path, mode, access, FileShare.None); } /// Opens a on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. /// A on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. /// The file to open. /// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten. /// A value that specifies the operations that can be performed on the file. /// A value specifying the type of access other threads have to the file. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by .-or- specified Read and specified Create, CreateNew, Truncate, or Append. /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid, (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file. /// /// specified a file that is read-only and is not Read.-or- specified a directory.-or- The caller does not have the required permission. -or- is and the specified file is a hidden file. /// /// , , or specified an invalid value. /// The file specified in was not found. /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x0600164A RID: 5706 RVA: 0x00055D00 File Offset: 0x00053F00 public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share) { return new FileStream(path, mode, access, share); } /// Opens an existing file for reading. /// A read-only on the specified path. /// The file to be opened for reading. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid, (for example, it is on an unmapped drive). /// /// specified a directory.-or- The caller does not have the required permission. /// The file specified in was not found. /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x0600164B RID: 5707 RVA: 0x00055D0C File Offset: 0x00053F0C public static FileStream OpenRead(string path) { return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); } /// Opens an existing UTF-8 encoded text file for reading. /// A on the specified path. /// The file to be opened for reading. /// The caller does not have the required permission. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid, (for example, it is on an unmapped drive). /// The file specified in was not found. /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x0600164C RID: 5708 RVA: 0x00055D18 File Offset: 0x00053F18 public static StreamReader OpenText(string path) { return new StreamReader(path); } /// Opens an existing file for writing. /// An unshared object on the specified path with access. /// The file to be opened for writing. /// The caller does not have the required permission.-or- specified a read-only file or directory. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid, (for example, it is on an unmapped drive). /// The file specified in was not found. /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x0600164D RID: 5709 RVA: 0x00055D20 File Offset: 0x00053F20 public static FileStream OpenWrite(string path) { return new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None); } /// Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file. /// The name of a file that replaces the file specified by . /// The name of the file being replaced. /// The name of the backup file. /// The path described by the parameter was not of a legal form.-or-The path described by the parameter was not of a legal form. /// The parameter is null. /// An invalid drive was specified. /// The file described by the current object could not be found.-or-The file described by the parameter could not be found. /// An I/O error occurred while opening the file.- or -The and parameters specify the same file. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The operating system is Windows 98 Second Edition or earlier and the files system is not NTFS. /// The or parameter specifies a file that is read-only.-or- This operation is not supported on the current platform.-or- Source or destination parameters specify a directory instead of a file.-or- The caller does not have the required permission. /// 1 /// /// /// // Token: 0x0600164E RID: 5710 RVA: 0x00055D2C File Offset: 0x00053F2C public static void Replace(string sourceFileName, string destinationFileName, string destinationBackupFileName) { File.Replace(sourceFileName, destinationFileName, destinationBackupFileName, false); } /// Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of the replaced file and optionally ignores merge errors. /// The name of a file that replaces the file specified by . /// The name of the file being replaced. /// The name of the backup file. /// true to ignore merge errors (such as attributes and access control lists (ACLs)) from the replaced file to the replacement file; otherwise, false. /// The path described by the parameter was not of a legal form.-or-The path described by the parameter was not of a legal form. /// The parameter is null. /// An invalid drive was specified. /// The file described by the current object could not be found.-or-The file described by the parameter could not be found. /// An I/O error occurred while opening the file.- or -The and parameters specify the same file. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The operating system is Windows 98 Second Edition or earlier and the files system is not NTFS. /// The or parameter specifies a file that is read-only.-or- This operation is not supported on the current platform.-or- Source or destination parameters specify a directory instead of a file.-or- The caller does not have the required permission. /// 1 /// /// /// // Token: 0x0600164F RID: 5711 RVA: 0x00055D38 File Offset: 0x00053F38 public static void Replace(string sourceFileName, string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors) { if (sourceFileName == null) { throw new ArgumentNullException("sourceFileName"); } if (destinationFileName == null) { throw new ArgumentNullException("destinationFileName"); } if (sourceFileName.Trim().Length == 0 || sourceFileName.IndexOfAny(Path.InvalidPathChars) != -1) { throw new ArgumentException("sourceFileName"); } if (destinationFileName.Trim().Length == 0 || destinationFileName.IndexOfAny(Path.InvalidPathChars) != -1) { throw new ArgumentException("destinationFileName"); } string fullPath = Path.GetFullPath(sourceFileName); string fullPath2 = Path.GetFullPath(destinationFileName); MonoIOError monoIOError; if (MonoIO.ExistsDirectory(fullPath, out monoIOError)) { throw new IOException(Locale.GetText("{0} is a directory", new object[] { sourceFileName })); } if (MonoIO.ExistsDirectory(fullPath2, out monoIOError)) { throw new IOException(Locale.GetText("{0} is a directory", new object[] { destinationFileName })); } if (!File.Exists(fullPath)) { throw new FileNotFoundException(Locale.GetText("{0} does not exist", new object[] { sourceFileName }), sourceFileName); } if (!File.Exists(fullPath2)) { throw new FileNotFoundException(Locale.GetText("{0} does not exist", new object[] { destinationFileName }), destinationFileName); } if (fullPath == fullPath2) { throw new IOException(Locale.GetText("Source and destination arguments are the same file.")); } string text = null; if (destinationBackupFileName != null) { if (destinationBackupFileName.Trim().Length == 0 || destinationBackupFileName.IndexOfAny(Path.InvalidPathChars) != -1) { throw new ArgumentException("destinationBackupFileName"); } text = Path.GetFullPath(destinationBackupFileName); if (MonoIO.ExistsDirectory(text, out monoIOError)) { throw new IOException(Locale.GetText("{0} is a directory", new object[] { destinationBackupFileName })); } if (fullPath == text) { throw new IOException(Locale.GetText("Source and backup arguments are the same file.")); } if (fullPath2 == text) { throw new IOException(Locale.GetText("Destination and backup arguments are the same file.")); } } if (!MonoIO.ReplaceFile(fullPath, fullPath2, text, ignoreMetadataErrors, out monoIOError)) { throw MonoIO.GetException(monoIOError); } } /// Sets the specified of the file on the specified path. /// The path to the file. /// A bitwise combination of the enumeration values. /// /// is empty, contains only white spaces, contains invalid characters, or the file attribute is invalid. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// /// is in an invalid format. /// The specified path is invalid, (for example, it is on an unmapped drive). /// The file cannot be found. /// /// specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. /// 1 /// /// /// // Token: 0x06001650 RID: 5712 RVA: 0x00055F34 File Offset: 0x00054134 public static void SetAttributes(string path, FileAttributes fileAttributes) { File.CheckPathExceptions(path); MonoIOError monoIOError; if (!MonoIO.SetFileAttributes(path, fileAttributes, out monoIOError)) { throw MonoIO.GetException(path, monoIOError); } } /// Sets the date and time the file was created. /// The file for which to set the creation date and time information. /// A containing the value to set for the creation date and time of . This value is expressed in local time. /// The specified path was not found. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// An I/O error occurred while performing the operation. /// /// specifies a value outside the range of dates, times, or both permitted for this operation. /// The caller does not have the required permission. /// /// is in an invalid format. /// 1 /// /// /// // Token: 0x06001651 RID: 5713 RVA: 0x00055F60 File Offset: 0x00054160 public static void SetCreationTime(string path, DateTime creationTime) { File.CheckPathExceptions(path); MonoIOError monoIOError; if (!MonoIO.Exists(path, out monoIOError)) { throw MonoIO.GetException(path, monoIOError); } if (!MonoIO.SetCreationTime(path, creationTime, out monoIOError)) { throw MonoIO.GetException(path, monoIOError); } } /// Sets the date and time, in coordinated universal time (UTC), that the file was created. /// The file for which to set the creation date and time information. /// A containing the value to set for the creation date and time of . This value is expressed in UTC time. /// The specified path was not found. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// An I/O error occurred while performing the operation. /// /// specifies a value outside the range of dates, times, or both permitted for this operation. /// The caller does not have the required permission. /// /// is in an invalid format. /// 2 /// /// /// // Token: 0x06001652 RID: 5714 RVA: 0x00055FA0 File Offset: 0x000541A0 public static void SetCreationTimeUtc(string path, DateTime creationTimeUtc) { File.SetCreationTime(path, creationTimeUtc.ToLocalTime()); } /// Sets the date and time the specified file was last accessed. /// The file for which to set the access date and time information. /// A containing the value to set for the last access date and time of . This value is expressed in local time. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path was not found. /// The caller does not have the required permission. /// /// is in an invalid format. /// /// specifies a value outside the range of dates or times permitted for this operation. /// 1 /// /// /// // Token: 0x06001653 RID: 5715 RVA: 0x00055FB0 File Offset: 0x000541B0 public static void SetLastAccessTime(string path, DateTime lastAccessTime) { File.CheckPathExceptions(path); MonoIOError monoIOError; if (!MonoIO.Exists(path, out monoIOError)) { throw MonoIO.GetException(path, monoIOError); } if (!MonoIO.SetLastAccessTime(path, lastAccessTime, out monoIOError)) { throw MonoIO.GetException(path, monoIOError); } } /// Sets the date and time, in coordinated universal time (UTC), that the specified file was last accessed. /// The file for which to set the access date and time information. /// A containing the value to set for the last access date and time of . This value is expressed in UTC time. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path was not found. /// The caller does not have the required permission. /// /// is in an invalid format. /// /// specifies a value outside the range of dates or times permitted for this operation. /// 1 /// /// /// // Token: 0x06001654 RID: 5716 RVA: 0x00055FF0 File Offset: 0x000541F0 public static void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc) { File.SetLastAccessTime(path, lastAccessTimeUtc.ToLocalTime()); } /// Sets the date and time that the specified file was last written to. /// The file for which to set the date and time information. /// A containing the value to set for the last write date and time of . This value is expressed in local time. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path was not found. /// The caller does not have the required permission. /// /// is in an invalid format. /// /// specifies a value outside the range of dates or times permitted for this operation. /// 1 /// /// /// // Token: 0x06001655 RID: 5717 RVA: 0x00056000 File Offset: 0x00054200 public static void SetLastWriteTime(string path, DateTime lastWriteTime) { File.CheckPathExceptions(path); MonoIOError monoIOError; if (!MonoIO.Exists(path, out monoIOError)) { throw MonoIO.GetException(path, monoIOError); } if (!MonoIO.SetLastWriteTime(path, lastWriteTime, out monoIOError)) { throw MonoIO.GetException(path, monoIOError); } } /// Sets the date and time, in coordinated universal time (UTC), that the specified file was last written to. /// The file for which to set the date and time information. /// A containing the value to set for the last write date and time of . This value is expressed in UTC time. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path was not found. /// The caller does not have the required permission. /// /// is in an invalid format. /// /// specifies a value outside the range of dates or times permitted for this operation. /// 2 /// /// /// // Token: 0x06001656 RID: 5718 RVA: 0x00056040 File Offset: 0x00054240 public static void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc) { File.SetLastWriteTime(path, lastWriteTimeUtc.ToLocalTime()); } // Token: 0x06001657 RID: 5719 RVA: 0x00056050 File Offset: 0x00054250 private static void CheckPathExceptions(string path) { if (path == null) { throw new ArgumentNullException("path"); } if (path.Length == 0) { throw new ArgumentException(Locale.GetText("Path is empty")); } if (path.Trim().Length == 0) { throw new ArgumentException(Locale.GetText("Path is empty")); } if (path.IndexOfAny(Path.InvalidPathChars) != -1) { throw new ArgumentException(Locale.GetText("Path contains invalid chars")); } } /// Opens a binary file, reads the contents of the file into a byte array, and then closes the file. /// A byte array containing the contents of the file. /// The file to open for reading. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file. /// This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. /// The file specified in was not found. /// /// is in an invalid format. /// The caller does not have the required permission. /// 1 /// /// /// // Token: 0x06001658 RID: 5720 RVA: 0x000560CC File Offset: 0x000542CC public static byte[] ReadAllBytes(string path) { byte[] array2; using (FileStream fileStream = File.OpenRead(path)) { long length = fileStream.Length; if (length > 2147483647L) { throw new IOException("Reading more than 2GB with this call is not supported"); } int num = 0; int i = (int)length; byte[] array = new byte[length]; while (i > 0) { int num2 = fileStream.Read(array, num, i); if (num2 == 0) { throw new IOException("Unexpected end of stream"); } num += num2; i -= num2; } array2 = array; } return array2; } /// Opens a text file, reads all lines of the file, and then closes the file. /// A string array containing all lines of the file. /// The file to open for reading. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file. /// /// specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. /// The file specified in was not found. /// /// is in an invalid format. /// The caller does not have the required permission. /// 1 /// /// /// // Token: 0x06001659 RID: 5721 RVA: 0x0005617C File Offset: 0x0005437C public static string[] ReadAllLines(string path) { string[] array; using (StreamReader streamReader = File.OpenText(path)) { array = File.ReadAllLines(streamReader); } return array; } /// Opens a file, reads all lines of the file with the specified encoding, and then closes the file. /// A string array containing all lines of the file. /// The file to open for reading. /// The encoding applied to the contents of the file. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file. /// /// specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. /// The file specified in was not found. /// /// is in an invalid format. /// The caller does not have the required permission. /// 1 /// /// /// // Token: 0x0600165A RID: 5722 RVA: 0x000561CC File Offset: 0x000543CC public static string[] ReadAllLines(string path, Encoding encoding) { string[] array; using (StreamReader streamReader = new StreamReader(path, encoding)) { array = File.ReadAllLines(streamReader); } return array; } // Token: 0x0600165B RID: 5723 RVA: 0x0005621C File Offset: 0x0005441C private static string[] ReadAllLines(StreamReader reader) { List list = new List(); while (!reader.EndOfStream) { list.Add(reader.ReadLine()); } return list.ToArray(); } /// Opens a text file, reads all lines of the file, and then closes the file. /// A string containing all lines of the file. /// The file to open for reading. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file. /// /// specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. /// The file specified in was not found. /// /// is in an invalid format. /// The caller does not have the required permission. /// 1 /// /// /// // Token: 0x0600165C RID: 5724 RVA: 0x00056254 File Offset: 0x00054454 public static string ReadAllText(string path) { return File.ReadAllText(path, Encoding.UTF8Unmarked); } /// Opens a file, reads all lines of the file with the specified encoding, and then closes the file. /// A string containing all lines of the file. /// The file to open for reading. /// The encoding applied to the contents of the file. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file. /// /// specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. /// The file specified in was not found. /// /// is in an invalid format. /// The caller does not have the required permission. /// 1 /// /// /// // Token: 0x0600165D RID: 5725 RVA: 0x00056264 File Offset: 0x00054464 public static string ReadAllText(string path, Encoding encoding) { string text; using (StreamReader streamReader = new StreamReader(path, encoding)) { text = streamReader.ReadToEnd(); } return text; } /// Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is overwritten. /// The file to write to. /// The bytes to write to the file. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null or the byte array is empty. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file.-or-An attempt is made to write a file that is larger than 64 MB to a network path. /// /// specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. /// The file specified in was not found. /// /// is in an invalid format. /// The caller does not have the required permission. /// 1 /// /// /// // Token: 0x0600165E RID: 5726 RVA: 0x000562B4 File Offset: 0x000544B4 public static void WriteAllBytes(string path, byte[] bytes) { using (Stream stream = File.Create(path)) { stream.Write(bytes, 0, bytes.Length); } } /// Creates a new file, write the specified string array to the file, and then closes the file. If the target file already exists, it is overwritten. /// The file to write to. /// The string array to write to the file. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// or is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file. /// /// specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. /// The file specified in was not found. /// /// is in an invalid format. /// The caller does not have the required permission. /// 1 /// /// /// // Token: 0x0600165F RID: 5727 RVA: 0x00056304 File Offset: 0x00054504 public static void WriteAllLines(string path, string[] contents) { using (StreamWriter streamWriter = new StreamWriter(path)) { File.WriteAllLines(streamWriter, contents); } } /// Creates a new file, writes the specified string array to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten. /// The file to write to. /// The string array to write to the file. /// An object that represents the character encoding applied to the string array. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// or is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file. /// /// specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. /// The file specified in was not found. /// /// is in an invalid format. /// The caller does not have the required permission. /// 1 /// /// /// // Token: 0x06001660 RID: 5728 RVA: 0x00056350 File Offset: 0x00054550 public static void WriteAllLines(string path, string[] contents, Encoding encoding) { using (StreamWriter streamWriter = new StreamWriter(path, false, encoding)) { File.WriteAllLines(streamWriter, contents); } } // Token: 0x06001661 RID: 5729 RVA: 0x0005639C File Offset: 0x0005459C private static void WriteAllLines(StreamWriter writer, string[] contents) { foreach (string text in contents) { writer.WriteLine(text); } } /// Creates a new file, writes the specified string to the file, and then closes the file. If the target file already exists, it is overwritten. /// The file to write to. /// The string to write to the file. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file. /// /// specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. /// The file specified in was not found. /// /// is in an invalid format. /// The caller does not have the required permission. /// 1 /// /// /// // Token: 0x06001662 RID: 5730 RVA: 0x000563CC File Offset: 0x000545CC public static void WriteAllText(string path, string contents) { File.WriteAllText(path, contents, Encoding.UTF8Unmarked); } /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten. /// The file to write to. /// The string to write to the file. /// An object that represents the encoding to apply to the string. /// /// is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// /// is null or contents string is empty. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The specified path is invalid (for example, it is on an unmapped drive). /// An I/O error occurred while opening the file. /// /// specified a file that is read-only.-or- This operation is not supported on the current platform.-or- specified a directory.-or- The caller does not have the required permission. /// The file specified in was not found. /// /// is in an invalid format. /// The caller does not have the required permission. /// 1 /// /// /// // Token: 0x06001663 RID: 5731 RVA: 0x000563DC File Offset: 0x000545DC public static void WriteAllText(string path, string contents, Encoding encoding) { using (StreamWriter streamWriter = new StreamWriter(path, false, encoding)) { streamWriter.Write(contents); } } // Token: 0x170003EB RID: 1003 // (get) Token: 0x06001664 RID: 5732 RVA: 0x00056428 File Offset: 0x00054628 private static DateTime DefaultLocalFileTime { get { DateTime? dateTime = File.defaultLocalFileTime; if (dateTime == null) { DateTime dateTime2 = new DateTime(1601, 1, 1); File.defaultLocalFileTime = new DateTime?(dateTime2.ToLocalTime()); } return File.defaultLocalFileTime.Value; } } /// Encrypts a file so that only the account used to encrypt the file can decrypt it. /// A path that describes a file to encrypt. /// The parameter is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// The parameter is null. /// An invalid drive was specified. /// The file described by the parameter could not be found. /// An I/O error occurred while opening the file.-or-This operation is not supported on the current platform. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The current operating system is not Microsoft Windows NT or later. /// The file system is not NTFS. /// The parameter specified a file that is read-only.-or- This operation is not supported on the current platform.-or- The parameter specified a directory.-or- The caller does not have the required permission. /// 1 /// /// /// // Token: 0x06001665 RID: 5733 RVA: 0x00056474 File Offset: 0x00054674 [MonoLimitation("File encryption isn't supported (even on NTFS).")] public static void Encrypt(string path) { throw new NotSupportedException(Locale.GetText("File encryption isn't supported on any file system.")); } /// Decrypts a file that was encrypted by the current account using the method. /// A path that describes a file to decrypt. /// The parameter is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . /// The parameter is null. /// An invalid drive was specified. /// The file described by the parameter could not be found. /// An I/O error occurred while opening the file. For example, the encrypted file is already open. -or-This operation is not supported on the current platform. /// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The current operating system is not Microsoft Windows NT or later. /// The file system is not NTFS. /// The parameter specified a file that is read-only.-or- This operation is not supported on the current platform.-or- The parameter specified a directory.-or- The caller does not have the required permission. /// 1 /// /// /// // Token: 0x06001666 RID: 5734 RVA: 0x00056488 File Offset: 0x00054688 [MonoLimitation("File encryption isn't supported (even on NTFS).")] public static void Decrypt(string path) { throw new NotSupportedException(Locale.GetText("File encryption isn't supported on any file system.")); } // Token: 0x0400065A RID: 1626 private static DateTime? defaultLocalFileTime; } }