Files
2026-06-04 11:42:34 +02:00

1480 lines
110 KiB
C#

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace System.IO
{
/// <summary>Provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of <see cref="T:System.IO.FileStream" /> objects.</summary>
/// <filterpriority>1</filterpriority>
// Token: 0x020001B2 RID: 434
[ComVisible(true)]
public static class File
{
/// <summary>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.</summary>
/// <param name="path">The file to append the specified string to. </param>
/// <param name="contents">The string to append to the file. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only.-or- This operation is not supported on the current platform.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
}
/// <summary>Appends the specified string to the file, creating the file if it does not already exist.</summary>
/// <param name="path">The file to append the specified string to. </param>
/// <param name="contents">The string to append to the file. </param>
/// <param name="encoding">The character encoding to use. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only.-or- This operation is not supported on the current platform.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
}
/// <summary>Creates a <see cref="T:System.IO.StreamWriter" /> that appends UTF-8 encoded text to an existing file.</summary>
/// <returns>A StreamWriter that appends UTF-8 encoded text to an existing file.</returns>
/// <param name="path">The path to the file to append to. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.-OR-<paramref name="destFileName" /> is read-only. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06001638 RID: 5688 RVA: 0x000556C0 File Offset: 0x000538C0
public static StreamWriter AppendText(string path)
{
return new StreamWriter(path, true);
}
/// <summary>Copies an existing file to a new file. Overwriting a file of the same name is not allowed.</summary>
/// <param name="sourceFileName">The file to copy. </param>
/// <param name="destFileName">The name of the destination file. This cannot be a directory or an existing file. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="sourceFileName" /> or <paramref name="destFileName" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />.-or- <paramref name="sourceFileName" /> or <paramref name="destFileName" /> specifies a directory. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="sourceFileName" /> or <paramref name="destFileName" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The path specified in <paramref name="sourceFileName" /> or <paramref name="destFileName" /> is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.FileNotFoundException">
/// <paramref name="sourceFileName" /> was not found. </exception>
/// <exception cref="T:System.IO.IOException">
/// <paramref name="destFileName" /> exists.-or- An I/O error has occurred. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="sourceFileName" /> or <paramref name="destFileName" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06001639 RID: 5689 RVA: 0x000556CC File Offset: 0x000538CC
public static void Copy(string sourceFileName, string destFileName)
{
File.Copy(sourceFileName, destFileName, false);
}
/// <summary>Copies an existing file to a new file. Overwriting a file of the same name is allowed.</summary>
/// <param name="sourceFileName">The file to copy. </param>
/// <param name="destFileName">The name of the destination file. This cannot be a directory. </param>
/// <param name="overwrite">true if the destination file can be overwritten; otherwise, false. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. -or-<paramref name="destFileName" /> is read-only.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="sourceFileName" /> or <paramref name="destFileName" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />.-or- <paramref name="sourceFileName" /> or <paramref name="destFileName" /> specifies a directory. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="sourceFileName" /> or <paramref name="destFileName" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The path specified in <paramref name="sourceFileName" /> or <paramref name="destFileName" /> is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.FileNotFoundException">
/// <paramref name="sourceFileName" /> was not found. </exception>
/// <exception cref="T:System.IO.IOException">
/// <paramref name="destFileName" /> exists and <paramref name="overwrite" /> is false.-or- An I/O error has occurred. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="sourceFileName" /> or <paramref name="destFileName" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
}
/// <summary>Creates or overwrites a file in the specified path.</summary>
/// <returns>A <see cref="T:System.IO.FileStream" /> that provides read/write access to the file specified in <paramref name="path" />.</returns>
/// <param name="path">The path and name of the file to create. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.-or- <paramref name="path" /> specified a file that is read-only. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while creating the file. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x0600163B RID: 5691 RVA: 0x000558AC File Offset: 0x00053AAC
public static FileStream Create(string path)
{
return File.Create(path, 8192);
}
/// <summary>Creates or overwrites the specified file.</summary>
/// <returns>A <see cref="T:System.IO.FileStream" /> with the specified buffer size that provides read/write access to the file specified in <paramref name="path" />.</returns>
/// <param name="path">The name of the file. </param>
/// <param name="bufferSize">The number of bytes buffered for reads and writes to the file. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.-or- <paramref name="path" /> specified a file that is read-only. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while creating the file. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
/// <summary>Creates or opens a file for writing UTF-8 encoded text.</summary>
/// <returns>A <see cref="T:System.IO.StreamWriter" /> that writes to the specified file using UTF-8 encoding.</returns>
/// <param name="path">The file to be opened for writing. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x0600163D RID: 5693 RVA: 0x000558C8 File Offset: 0x00053AC8
public static StreamWriter CreateText(string path)
{
return new StreamWriter(path, false);
}
/// <summary>Deletes the specified file. An exception is not thrown if the specified file does not exist.</summary>
/// <param name="path">The name of the file to be deleted. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">The specified file is in use. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.-or- <paramref name="path" /> is a directory.-or- <paramref name="path" /> specified a read-only file. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
}
/// <summary>Determines whether the specified file exists.</summary>
/// <returns>true if the caller has the required permissions and <paramref name="path" /> contains the name of an existing file; otherwise, false. This method also returns false if <paramref name="path" /> 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 <paramref name="path" />.</returns>
/// <param name="path">The file to check. </param>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
/// <summary>Gets the <see cref="T:System.IO.FileAttributes" /> of the file on the path.</summary>
/// <returns>The <see cref="T:System.IO.FileAttributes" /> of the file on the path.</returns>
/// <param name="path">The path to the file. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is empty, contains only white spaces, or contains invalid characters. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">
/// <paramref name="path" /> represents a file and is invalid, such as being on an unmapped drive, or the file cannot be found. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">
/// <paramref name="path" /> represents a directory and is invalid, such as being on an unmapped drive, or the directory cannot be found.</exception>
/// <exception cref="T:System.IO.IOException">This file is being used by another process.</exception>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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;
}
/// <summary>Returns the creation date and time of the specified file or directory.</summary>
/// <returns>A <see cref="T:System.DateTime" /> structure set to the creation date and time for the specified file or directory. This value is expressed in local time.</returns>
/// <param name="path">The file or directory for which to obtain creation date and time information. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
/// <summary>Returns the creation date and time, in coordinated universal time (UTC), of the specified file or directory.</summary>
/// <returns>A <see cref="T:System.DateTime" /> structure set to the creation date and time for the specified file or directory. This value is expressed in UTC time.</returns>
/// <param name="path">The file or directory for which to obtain creation date and time information. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>2</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06001642 RID: 5698 RVA: 0x00055AA0 File Offset: 0x00053CA0
public static DateTime GetCreationTimeUtc(string path)
{
return File.GetCreationTime(path).ToUniversalTime();
}
/// <summary>Returns the date and time the specified file or directory was last accessed.</summary>
/// <returns>A <see cref="T:System.DateTime" /> structure set to the date and time that the specified file or directory was last accessed. This value is expressed in local time.</returns>
/// <param name="path">The file or directory for which to obtain access date and time information. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
/// <summary>Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last accessed.</summary>
/// <returns>A <see cref="T:System.DateTime" /> structure set to the date and time that the specified file or directory was last accessed. This value is expressed in UTC time.</returns>
/// <param name="path">The file or directory for which to obtain access date and time information. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06001644 RID: 5700 RVA: 0x00055B08 File Offset: 0x00053D08
public static DateTime GetLastAccessTimeUtc(string path)
{
return File.GetLastAccessTime(path).ToUniversalTime();
}
/// <summary>Returns the date and time the specified file or directory was last written to.</summary>
/// <returns>A <see cref="T:System.DateTime" /> structure set to the date and time that the specified file or directory was last written to. This value is expressed in local time.</returns>
/// <param name="path">The file or directory for which to obtain write date and time information. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
/// <summary>Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last written to.</summary>
/// <returns>A <see cref="T:System.DateTime" /> structure set to the date and time that the specified file or directory was last written to. This value is expressed in UTC time.</returns>
/// <param name="path">The file or directory for which to obtain write date and time information. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>2</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06001646 RID: 5702 RVA: 0x00055B70 File Offset: 0x00053D70
public static DateTime GetLastWriteTimeUtc(string path)
{
return File.GetLastWriteTime(path).ToUniversalTime();
}
/// <summary>Moves a specified file to a new location, providing the option to specify a new file name.</summary>
/// <param name="sourceFileName">The name of the file to move. </param>
/// <param name="destFileName">The new path for the file. </param>
/// <exception cref="T:System.IO.IOException">The destination file already exists.-or-<paramref name="sourceFileName" /> was not found.</exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="sourceFileName" /> or <paramref name="destFileName" /> is null. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="sourceFileName" /> or <paramref name="destFileName" /> is a zero-length string, contains only white space, or contains invalid characters as defined in <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The path specified in <paramref name="sourceFileName" /> or <paramref name="destFileName" /> is invalid, (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="sourceFileName" /> or <paramref name="destFileName" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
/// <summary>Opens a <see cref="T:System.IO.FileStream" /> on the specified path with read/write access.</summary>
/// <returns>A <see cref="T:System.IO.FileStream" /> opened in the specified mode and path, with read/write access and not shared.</returns>
/// <param name="path">The file to open. </param>
/// <param name="mode">A <see cref="T:System.IO.FileMode" /> 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. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only.-or- This operation is not supported on the current platform.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. -or-<paramref name="mode" /> is <see cref="F:System.IO.FileMode.Create" /> and the specified file is a hidden file.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="mode" /> specified an invalid value. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
/// <summary>Opens a <see cref="T:System.IO.FileStream" /> on the specified path, with the specified mode and access.</summary>
/// <returns>An unshared <see cref="T:System.IO.FileStream" /> that provides access to the specified file, with the specified mode and access.</returns>
/// <param name="path">The file to open. </param>
/// <param name="mode">A <see cref="T:System.IO.FileMode" /> 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. </param>
/// <param name="access">A <see cref="T:System.IO.FileAccess" /> value that specifies the operations that can be performed on the file. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />.-or- <paramref name="access" /> specified Read and <paramref name="mode" /> specified Create, CreateNew, Truncate, or Append. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only and <paramref name="access" /> is not Read.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. -or-<paramref name="mode" /> is <see cref="F:System.IO.FileMode.Create" /> and the specified file is a hidden file.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="mode" /> or <paramref name="access" /> specified an invalid value. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
/// <summary>Opens a <see cref="T:System.IO.FileStream" /> on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option.</summary>
/// <returns>A <see cref="T:System.IO.FileStream" /> on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option.</returns>
/// <param name="path">The file to open. </param>
/// <param name="mode">A <see cref="T:System.IO.FileMode" /> 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. </param>
/// <param name="access">A <see cref="T:System.IO.FileAccess" /> value that specifies the operations that can be performed on the file. </param>
/// <param name="share">A <see cref="T:System.IO.FileShare" /> value specifying the type of access other threads have to the file. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />.-or- <paramref name="access" /> specified Read and <paramref name="mode" /> specified Create, CreateNew, Truncate, or Append. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only and <paramref name="access" /> is not Read.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. -or-<paramref name="mode" /> is <see cref="F:System.IO.FileMode.Create" /> and the specified file is a hidden file.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="mode" />, <paramref name="access" />, or <paramref name="share" /> specified an invalid value. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
/// <summary>Opens an existing file for reading.</summary>
/// <returns>A read-only <see cref="T:System.IO.FileStream" /> on the specified path.</returns>
/// <param name="path">The file to be opened for reading. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
/// <summary>Opens an existing UTF-8 encoded text file for reading.</summary>
/// <returns>A <see cref="T:System.IO.StreamReader" /> on the specified path.</returns>
/// <param name="path">The file to be opened for reading. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x0600164C RID: 5708 RVA: 0x00055D18 File Offset: 0x00053F18
public static StreamReader OpenText(string path)
{
return new StreamReader(path);
}
/// <summary>Opens an existing file for writing.</summary>
/// <returns>An unshared <see cref="T:System.IO.FileStream" /> object on the specified path with <see cref="F:System.IO.FileAccess.Write" /> access.</returns>
/// <param name="path">The file to be opened for writing. </param>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.-or- <paramref name="path" /> specified a read-only file or directory. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
/// <summary>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.</summary>
/// <param name="sourceFileName">The name of a file that replaces the file specified by <paramref name="destinationFileName" />.</param>
/// <param name="destinationFileName">The name of the file being replaced.</param>
/// <param name="destinationBackupFileName">The name of the backup file.</param>
/// <exception cref="T:System.ArgumentException">The path described by the <paramref name="destinationFileName" /> parameter was not of a legal form.-or-The path described by the <paramref name="destinationBackupFileName" /> parameter was not of a legal form.</exception>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="destinationFileName" /> parameter is null.</exception>
/// <exception cref="T:System.IO.DriveNotFoundException">An invalid drive was specified. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file described by the current <see cref="T:System.IO.FileInfo" /> object could not be found.-or-The file described by the <paramref name="destinationBackupFileName" /> parameter could not be found. </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file.- or -The <paramref name="sourceFileName" /> and <paramref name="destinationFileName" /> parameters specify the same file.</exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.PlatformNotSupportedException">The operating system is Windows 98 Second Edition or earlier and the files system is not NTFS.</exception>
/// <exception cref="T:System.UnauthorizedAccessException">The <paramref name="sourceFileName" /> or <paramref name="destinationFileName" /> 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.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
/// <summary>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.</summary>
/// <param name="sourceFileName">The name of a file that replaces the file specified by <paramref name="destinationFileName" />.</param>
/// <param name="destinationFileName">The name of the file being replaced.</param>
/// <param name="destinationBackupFileName">The name of the backup file.</param>
/// <param name="ignoreMetadataErrors">true to ignore merge errors (such as attributes and access control lists (ACLs)) from the replaced file to the replacement file; otherwise, false. </param>
/// <exception cref="T:System.ArgumentException">The path described by the <paramref name="destinationFileName" /> parameter was not of a legal form.-or-The path described by the <paramref name="destinationBackupFileName" /> parameter was not of a legal form.</exception>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="destinationFileName" /> parameter is null.</exception>
/// <exception cref="T:System.IO.DriveNotFoundException">An invalid drive was specified. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file described by the current <see cref="T:System.IO.FileInfo" /> object could not be found.-or-The file described by the <paramref name="destinationBackupFileName" /> parameter could not be found. </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file.- or -The <paramref name="sourceFileName" /> and <paramref name="destinationFileName" /> parameters specify the same file.</exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.PlatformNotSupportedException">The operating system is Windows 98 Second Edition or earlier and the files system is not NTFS.</exception>
/// <exception cref="T:System.UnauthorizedAccessException">The <paramref name="sourceFileName" /> or <paramref name="destinationFileName" /> 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.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
}
/// <summary>Sets the specified <see cref="T:System.IO.FileAttributes" /> of the file on the specified path.</summary>
/// <param name="path">The path to the file. </param>
/// <param name="fileAttributes">A bitwise combination of the enumeration values. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is empty, contains only white spaces, contains invalid characters, or the file attribute is invalid. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid, (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file cannot be found.</exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only.-or- This operation is not supported on the current platform.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
}
/// <summary>Sets the date and time the file was created.</summary>
/// <param name="path">The file for which to set the creation date and time information. </param>
/// <param name="creationTime">A <see cref="T:System.DateTime" /> containing the value to set for the creation date and time of <paramref name="path" />. This value is expressed in local time. </param>
/// <exception cref="T:System.IO.FileNotFoundException">The specified path was not found. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while performing the operation. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="creationTime" /> specifies a value outside the range of dates, times, or both permitted for this operation. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
}
/// <summary>Sets the date and time, in coordinated universal time (UTC), that the file was created.</summary>
/// <param name="path">The file for which to set the creation date and time information. </param>
/// <param name="creationTimeUtc">A <see cref="T:System.DateTime" /> containing the value to set for the creation date and time of <paramref name="path" />. This value is expressed in UTC time. </param>
/// <exception cref="T:System.IO.FileNotFoundException">The specified path was not found. </exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while performing the operation. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="creationTime" /> specifies a value outside the range of dates, times, or both permitted for this operation. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <filterpriority>2</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06001652 RID: 5714 RVA: 0x00055FA0 File Offset: 0x000541A0
public static void SetCreationTimeUtc(string path, DateTime creationTimeUtc)
{
File.SetCreationTime(path, creationTimeUtc.ToLocalTime());
}
/// <summary>Sets the date and time the specified file was last accessed.</summary>
/// <param name="path">The file for which to set the access date and time information. </param>
/// <param name="lastAccessTime">A <see cref="T:System.DateTime" /> containing the value to set for the last access date and time of <paramref name="path" />. This value is expressed in local time. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The specified path was not found. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="lastAccessTime" /> specifies a value outside the range of dates or times permitted for this operation.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
}
/// <summary>Sets the date and time, in coordinated universal time (UTC), that the specified file was last accessed.</summary>
/// <param name="path">The file for which to set the access date and time information. </param>
/// <param name="lastAccessTimeUtc">A <see cref="T:System.DateTime" /> containing the value to set for the last access date and time of <paramref name="path" />. This value is expressed in UTC time. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The specified path was not found. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="lastAccessTimeUtc" /> specifies a value outside the range of dates or times permitted for this operation.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06001654 RID: 5716 RVA: 0x00055FF0 File Offset: 0x000541F0
public static void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc)
{
File.SetLastAccessTime(path, lastAccessTimeUtc.ToLocalTime());
}
/// <summary>Sets the date and time that the specified file was last written to.</summary>
/// <param name="path">The file for which to set the date and time information. </param>
/// <param name="lastWriteTime">A <see cref="T:System.DateTime" /> containing the value to set for the last write date and time of <paramref name="path" />. This value is expressed in local time. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The specified path was not found. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="lastWriteTime" /> specifies a value outside the range of dates or times permitted for this operation.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
}
/// <summary>Sets the date and time, in coordinated universal time (UTC), that the specified file was last written to.</summary>
/// <param name="path">The file for which to set the date and time information. </param>
/// <param name="lastWriteTimeUtc">A <see cref="T:System.DateTime" /> containing the value to set for the last write date and time of <paramref name="path" />. This value is expressed in UTC time. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The specified path was not found. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="lastWriteTimeUtc" /> specifies a value outside the range of dates or times permitted for this operation.</exception>
/// <filterpriority>2</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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"));
}
}
/// <summary>Opens a binary file, reads the contents of the file into a byte array, and then closes the file.</summary>
/// <returns>A byte array containing the contents of the file.</returns>
/// <param name="path">The file to open for reading. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">This operation is not supported on the current platform.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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;
}
/// <summary>Opens a text file, reads all lines of the file, and then closes the file.</summary>
/// <returns>A string array containing all lines of the file.</returns>
/// <param name="path">The file to open for reading. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only.-or- This operation is not supported on the current platform.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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;
}
/// <summary>Opens a file, reads all lines of the file with the specified encoding, and then closes the file.</summary>
/// <returns>A string array containing all lines of the file.</returns>
/// <param name="path">The file to open for reading. </param>
/// <param name="encoding">The encoding applied to the contents of the file. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only.-or- This operation is not supported on the current platform.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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<string> list = new List<string>();
while (!reader.EndOfStream)
{
list.Add(reader.ReadLine());
}
return list.ToArray();
}
/// <summary>Opens a text file, reads all lines of the file, and then closes the file.</summary>
/// <returns>A string containing all lines of the file.</returns>
/// <param name="path">The file to open for reading. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only.-or- This operation is not supported on the current platform.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x0600165C RID: 5724 RVA: 0x00056254 File Offset: 0x00054454
public static string ReadAllText(string path)
{
return File.ReadAllText(path, Encoding.UTF8Unmarked);
}
/// <summary>Opens a file, reads all lines of the file with the specified encoding, and then closes the file.</summary>
/// <returns>A string containing all lines of the file.</returns>
/// <param name="path">The file to open for reading. </param>
/// <param name="encoding">The encoding applied to the contents of the file. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only.-or- This operation is not supported on the current platform.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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;
}
/// <summary>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.</summary>
/// <param name="path">The file to write to. </param>
/// <param name="bytes">The bytes to write to the file. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null or the byte array is empty. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">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.</exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only.-or- This operation is not supported on the current platform.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
}
/// <summary>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.</summary>
/// <param name="path">The file to write to. </param>
/// <param name="contents">The string array to write to the file. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> or <paramref name="contents" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only.-or- This operation is not supported on the current platform.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
}
/// <summary>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.</summary>
/// <param name="path">The file to write to. </param>
/// <param name="contents">The string array to write to the file. </param>
/// <param name="encoding">An <see cref="T:System.Text.Encoding" /> object that represents the character encoding applied to the string array.</param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> or <paramref name="contents" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only.-or- This operation is not supported on the current platform.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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);
}
}
/// <summary>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.</summary>
/// <param name="path">The file to write to. </param>
/// <param name="contents">The string to write to the file. </param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only.-or- This operation is not supported on the current platform.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// Token: 0x06001662 RID: 5730 RVA: 0x000563CC File Offset: 0x000545CC
public static void WriteAllText(string path, string contents)
{
File.WriteAllText(path, contents, Encoding.UTF8Unmarked);
}
/// <summary>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.</summary>
/// <param name="path">The file to write to. </param>
/// <param name="contents">The string to write to the file. </param>
/// <param name="encoding">An <see cref="T:System.Text.Encoding" /> object that represents the encoding to apply to the string.</param>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />. </exception>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="path" /> is null or contents string is empty. </exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file. </exception>
/// <exception cref="T:System.UnauthorizedAccessException">
/// <paramref name="path" /> specified a file that is read-only.-or- This operation is not supported on the current platform.-or- <paramref name="path" /> specified a directory.-or- The caller does not have the required permission. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file specified in <paramref name="path" /> was not found. </exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="path" /> is in an invalid format. </exception>
/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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;
}
}
/// <summary>Encrypts a file so that only the account used to encrypt the file can decrypt it.</summary>
/// <param name="path">A path that describes a file to encrypt.</param>
/// <exception cref="T:System.ArgumentException">The <paramref name="path" /> parameter is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />.</exception>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="path" /> parameter is null.</exception>
/// <exception cref="T:System.IO.DriveNotFoundException">An invalid drive was specified. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file described by the <paramref name="path" /> parameter could not be found.</exception>
/// <exception cref="T:System.IO.IOException">An I/O error occurred while opening the file.-or-This operation is not supported on the current platform.</exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.PlatformNotSupportedException">The current operating system is not Microsoft Windows NT or later.</exception>
/// <exception cref="T:System.NotSupportedException">The file system is not NTFS.</exception>
/// <exception cref="T:System.UnauthorizedAccessException">The <paramref name="path" /> parameter specified a file that is read-only.-or- This operation is not supported on the current platform.-or- The <paramref name="path" /> parameter specified a directory.-or- The caller does not have the required permission.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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."));
}
/// <summary>Decrypts a file that was encrypted by the current account using the <see cref="M:System.IO.File.Encrypt(System.String)" /> method.</summary>
/// <param name="path">A path that describes a file to decrypt.</param>
/// <exception cref="T:System.ArgumentException">The <paramref name="path" /> parameter is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />.</exception>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="path" /> parameter is null.</exception>
/// <exception cref="T:System.IO.DriveNotFoundException">An invalid drive was specified. </exception>
/// <exception cref="T:System.IO.FileNotFoundException">The file described by the <paramref name="path" /> parameter could not be found.</exception>
/// <exception cref="T:System.IO.IOException">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.</exception>
/// <exception cref="T:System.IO.PathTooLongException">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. </exception>
/// <exception cref="T:System.PlatformNotSupportedException">The current operating system is not Microsoft Windows NT or later.</exception>
/// <exception cref="T:System.NotSupportedException">The file system is not NTFS.</exception>
/// <exception cref="T:System.UnauthorizedAccessException">The <paramref name="path" /> parameter specified a file that is read-only.-or- This operation is not supported on the current platform.-or- The <paramref name="path" /> parameter specified a directory.-or- The caller does not have the required permission.</exception>
/// <filterpriority>1</filterpriority>
/// <PermissionSet>
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
/// </PermissionSet>
// 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;
}
}