using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
namespace System.IO
{
/// Exposes instance methods for creating, moving, and enumerating through directories and subdirectories. This class cannot be inherited.
/// 1
// Token: 0x020001AB RID: 427
[ComVisible(true)]
[Serializable]
public sealed class DirectoryInfo : FileSystemInfo
{
/// Initializes a new instance of the class on the specified path.
/// A string specifying the path on which to create the DirectoryInfo.
///
/// is null.
/// The caller does not have the required permission.
///
/// contains invalid characters such as ", <, >, or |.
/// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. The specified path, file name, or both are too long.
// Token: 0x060015FD RID: 5629 RVA: 0x00054A68 File Offset: 0x00052C68
public DirectoryInfo(string path)
: this(path, false)
{
}
// Token: 0x060015FE RID: 5630 RVA: 0x00054A74 File Offset: 0x00052C74
internal DirectoryInfo(string path, bool simpleOriginalPath)
{
base.CheckPath(path);
this.FullPath = Path.GetFullPath(path);
if (simpleOriginalPath)
{
this.OriginalPath = Path.GetFileName(path);
}
else
{
this.OriginalPath = path;
}
this.Initialize();
}
// Token: 0x060015FF RID: 5631 RVA: 0x00054AC0 File Offset: 0x00052CC0
private DirectoryInfo(SerializationInfo info, StreamingContext context)
: base(info, context)
{
this.Initialize();
}
// Token: 0x06001600 RID: 5632 RVA: 0x00054AD0 File Offset: 0x00052CD0
private void Initialize()
{
int num = this.FullPath.Length - 1;
if (num > 1 && this.FullPath[num] == Path.DirectorySeparatorChar)
{
num--;
}
int num2 = this.FullPath.LastIndexOf(Path.DirectorySeparatorChar, num);
if (num2 == -1 || (num2 == 0 && num == 0))
{
this.current = this.FullPath;
this.parent = null;
}
else
{
this.current = this.FullPath.Substring(num2 + 1, num - num2);
if (num2 == 0 && !Environment.IsRunningOnWindows)
{
this.parent = Path.DirectorySeparatorStr;
}
else
{
this.parent = this.FullPath.Substring(0, num2);
}
if (Environment.IsRunningOnWindows && this.parent.Length == 2 && this.parent[1] == ':' && char.IsLetter(this.parent[0]))
{
this.parent += Path.DirectorySeparatorChar;
}
}
}
/// Gets a value indicating whether the directory exists.
/// true if the directory exists; otherwise, false.
/// 1
// Token: 0x170003DE RID: 990
// (get) Token: 0x06001601 RID: 5633 RVA: 0x00054BF4 File Offset: 0x00052DF4
public override bool Exists
{
get
{
base.Refresh(false);
return this.stat.Attributes != MonoIO.InvalidFileAttributes && (this.stat.Attributes & FileAttributes.Directory) != (FileAttributes)0;
}
}
/// Gets the name of this instance.
/// The directory name.
/// 1
// Token: 0x170003DF RID: 991
// (get) Token: 0x06001602 RID: 5634 RVA: 0x00054C38 File Offset: 0x00052E38
public override string Name
{
get
{
return this.current;
}
}
/// Gets the parent directory of a specified subdirectory.
/// The parent directory, or null if the path is null or if the file path denotes a root (such as "\", "C:", or * "\\server\share").
/// The caller does not have the required permission.
/// 1
///
///
///
// Token: 0x170003E0 RID: 992
// (get) Token: 0x06001603 RID: 5635 RVA: 0x00054C40 File Offset: 0x00052E40
public DirectoryInfo Parent
{
get
{
if (this.parent == null || this.parent.Length == 0)
{
return null;
}
return new DirectoryInfo(this.parent);
}
}
/// Gets the root portion of a path.
/// A object representing the root of a path.
/// The caller does not have the required permission.
/// 1
///
///
///
// Token: 0x170003E1 RID: 993
// (get) Token: 0x06001604 RID: 5636 RVA: 0x00054C78 File Offset: 0x00052E78
public DirectoryInfo Root
{
get
{
string pathRoot = Path.GetPathRoot(this.FullPath);
if (pathRoot == null)
{
return null;
}
return new DirectoryInfo(pathRoot);
}
}
/// Creates a directory.
/// The directory cannot be created.
/// 1
///
///
///
// Token: 0x06001605 RID: 5637 RVA: 0x00054CA0 File Offset: 0x00052EA0
public void Create()
{
Directory.CreateDirectory(this.FullPath);
}
/// Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to this instance of the class.
/// The last directory specified in .
/// The specified path. This cannot be a different disk volume or Universal Naming Convention (UNC) name.
///
/// does not specify a valid file path or contains invalid DirectoryInfo characters.
///
/// is null.
/// The specified path is invalid, such as being on an unmapped drive.
/// The subdirectory cannot be created.-or- A file or directory already has the name specified by .
/// The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. The specified path, file name, or both are too long.
/// The caller does not have code access permission to create the directory.-or-The caller does not have code access permission to read the directory described by the returned object. This can occur when the parameter describes an existing directory.
///
/// contains a colon (:) that is not part of a drive label ("C:\").
/// 2
///
///
///
// Token: 0x06001606 RID: 5638 RVA: 0x00054CB0 File Offset: 0x00052EB0
public DirectoryInfo CreateSubdirectory(string path)
{
base.CheckPath(path);
path = Path.Combine(this.FullPath, path);
Directory.CreateDirectory(path);
return new DirectoryInfo(path);
}
/// Returns a file list from the current directory.
/// An array of type .
/// The path is invalid, such as being on an unmapped drive.
/// 1
///
///
///
// Token: 0x06001607 RID: 5639 RVA: 0x00054CE0 File Offset: 0x00052EE0
public FileInfo[] GetFiles()
{
return this.GetFiles("*");
}
/// Returns a file list from the current directory matching the given .
/// An array of type .
/// The search string, such as "*.txt".
///
/// contains invalid characters. To determine the invalid characters, use the method.
///
/// is null.
/// The path is invalid, such as being on an unmapped drive.
/// The caller does not have the required permission.
/// 1
///
///
///
// Token: 0x06001608 RID: 5640 RVA: 0x00054CF0 File Offset: 0x00052EF0
public FileInfo[] GetFiles(string searchPattern)
{
if (searchPattern == null)
{
throw new ArgumentNullException("searchPattern");
}
string[] files = Directory.GetFiles(this.FullPath, searchPattern);
FileInfo[] array = new FileInfo[files.Length];
int num = 0;
foreach (string text in files)
{
array[num++] = new FileInfo(text);
}
return array;
}
/// Returns the subdirectories of the current directory.
/// An array of objects.
/// The path encapsulated in the DirectoryInfo object is invalid, such as being on an unmapped drive.
/// The caller does not have the required permission.
/// 1
///
///
///
// Token: 0x06001609 RID: 5641 RVA: 0x00054D58 File Offset: 0x00052F58
public DirectoryInfo[] GetDirectories()
{
return this.GetDirectories("*");
}
/// Returns an array of directories in the current matching the given search criteria.
/// An array of type DirectoryInfo matching .
/// The search string, such as "System*", used to search for all directories beginning with the word "System".
///
/// contains invalid characters. To determine the invalid characters, use the method.
///
/// is null.
/// The path encapsulated in the DirectoryInfo object is invalid, such as being on an unmapped drive.
/// The caller does not have the required permission.
/// 1
///
///
///
// Token: 0x0600160A RID: 5642 RVA: 0x00054D68 File Offset: 0x00052F68
public DirectoryInfo[] GetDirectories(string searchPattern)
{
if (searchPattern == null)
{
throw new ArgumentNullException("searchPattern");
}
string[] directories = Directory.GetDirectories(this.FullPath, searchPattern);
DirectoryInfo[] array = new DirectoryInfo[directories.Length];
int num = 0;
foreach (string text in directories)
{
array[num++] = new DirectoryInfo(text);
}
return array;
}
/// Returns an array of strongly typed entries representing all the files and subdirectories in a directory.
/// An array of strongly typed entries.
/// The path is invalid, such as being on an unmapped drive.
/// 2
///
///
///
// Token: 0x0600160B RID: 5643 RVA: 0x00054DD0 File Offset: 0x00052FD0
public FileSystemInfo[] GetFileSystemInfos()
{
return this.GetFileSystemInfos("*");
}
/// Retrieves an array of strongly typed objects representing the files and subdirectories matching the specified search criteria.
/// An array of strongly typed FileSystemInfo objects matching the search criteria.
/// The search string, such as "System*", used to search for all directories beginning with the word "System".
///
/// contains invalid characters. To determine the invalid characters, use the method.
///
/// is null.
/// The specified path is invalid, such as being on an unmapped drive.
/// The caller does not have the required permission.
/// 2
///
///
///
// Token: 0x0600160C RID: 5644 RVA: 0x00054DE0 File Offset: 0x00052FE0
public FileSystemInfo[] GetFileSystemInfos(string searchPattern)
{
if (searchPattern == null)
{
throw new ArgumentNullException("searchPattern");
}
if (!Directory.Exists(this.FullPath))
{
throw new IOException("Invalid directory");
}
string[] directories = Directory.GetDirectories(this.FullPath, searchPattern);
string[] files = Directory.GetFiles(this.FullPath, searchPattern);
FileSystemInfo[] array = new FileSystemInfo[directories.Length + files.Length];
int num = 0;
foreach (string text in directories)
{
array[num++] = new DirectoryInfo(text);
}
foreach (string text2 in files)
{
array[num++] = new FileInfo(text2);
}
return array;
}
/// Deletes this if it is empty.
/// The directory contains a read-only file.
/// The directory described by this object does not exist or could not be found.
/// The directory is not empty. -or-The directory is the application's current working directory.
/// The caller does not have the required permission.
/// 1
///
///
///
// Token: 0x0600160D RID: 5645 RVA: 0x00054EA8 File Offset: 0x000530A8
public override void Delete()
{
this.Delete(false);
}
/// Deletes this instance of a , specifying whether to delete subdirectories and files.
/// true to delete this directory, its subdirectories, and all files; otherwise, false.
/// The directory contains a read-only file.
/// The directory is read-only.-or- The directory contains one or more files or subdirectories and is false.-or-The directory is the application's current working directory.
/// The caller does not have the required permission.
/// 1
///
///
///
// Token: 0x0600160E RID: 5646 RVA: 0x00054EB4 File Offset: 0x000530B4
public void Delete(bool recursive)
{
Directory.Delete(this.FullPath, recursive);
}
/// Moves a instance and its contents to a new path.
/// The name and path to which to move this directory. The destination cannot be another disk volume or a directory with the identical name. It can be an existing directory to which you want to add this directory as a subdirectory.
///
/// is null.
///
/// is an empty string (''").
/// An attempt was made to move a directory to a different volume. -or- already exists.-or-You are not authorized to access this path.-or- The directory being moved and the destination directory have the same name.
/// The caller does not have the required permission.
/// The destination directory cannot be found.
/// 1
///
///
///
// Token: 0x0600160F RID: 5647 RVA: 0x00054EC4 File Offset: 0x000530C4
public void MoveTo(string destDirName)
{
if (destDirName == null)
{
throw new ArgumentNullException("destDirName");
}
if (destDirName.Length == 0)
{
throw new ArgumentException("An empty file name is not valid.", "destDirName");
}
Directory.Move(this.FullPath, Path.GetFullPath(destDirName));
}
/// Returns the original path that was passed by the user.
/// Returns the original path that was passed by the user.
/// 2
// Token: 0x06001610 RID: 5648 RVA: 0x00054F04 File Offset: 0x00053104
public override string ToString()
{
return this.OriginalPath;
}
/// Returns an array of directories in the current matching the given search criteria and using a value to determine whether to search subdirectories.
/// An array of type DirectoryInfo matching .
/// The search string, such as "System*", used to search for all directories beginning with the word "System".
/// One of the values of the enumeration that specifies whether the search operation should include only the current directory or should include all subdirectories.
///
/// contains invalid characters. To determine the invalid characters, use the method.
///
/// is null.
/// The path encapsulated in the DirectoryInfo object is invalid, such as being on an unmapped drive.
/// The caller does not have the required permission.
// Token: 0x06001611 RID: 5649 RVA: 0x00054F0C File Offset: 0x0005310C
public DirectoryInfo[] GetDirectories(string searchPattern, SearchOption searchOption)
{
if (searchOption == SearchOption.TopDirectoryOnly)
{
return this.GetDirectories(searchPattern);
}
if (searchOption != SearchOption.AllDirectories)
{
string text = Locale.GetText("Invalid enum value '{0}' for '{1}'.", new object[] { searchOption, "SearchOption" });
throw new ArgumentOutOfRangeException("searchOption", text);
}
Queue queue = new Queue(this.GetDirectories(searchPattern));
Queue queue2 = new Queue();
while (queue.Count > 0)
{
DirectoryInfo directoryInfo = (DirectoryInfo)queue.Dequeue();
DirectoryInfo[] directories = directoryInfo.GetDirectories(searchPattern);
foreach (DirectoryInfo directoryInfo2 in directories)
{
queue.Enqueue(directoryInfo2);
}
queue2.Enqueue(directoryInfo);
}
DirectoryInfo[] array2 = new DirectoryInfo[queue2.Count];
queue2.CopyTo(array2, 0);
return array2;
}
// Token: 0x06001612 RID: 5650 RVA: 0x00054FEC File Offset: 0x000531EC
internal int GetFilesSubdirs(ArrayList l, string pattern)
{
FileInfo[] array = null;
try
{
array = this.GetFiles(pattern);
}
catch (UnauthorizedAccessException)
{
return 0;
}
int num = array.Length;
l.Add(array);
foreach (DirectoryInfo directoryInfo in this.GetDirectories())
{
num += directoryInfo.GetFilesSubdirs(l, pattern);
}
return num;
}
/// Returns a file list from the current directory matching the given and using a value to determine whether to search subdirectories.
/// An array of type .
/// The search string, such as "System*", used to search for all directories beginning with the word "System".
/// One of the values of the enumeration that specifies whether the search operation should include only the current directory or should include all subdirectories.
///
/// contains invalid characters. To determine invalid characters, use the method.
///
/// is null.
///
/// is not a valid value.
/// The path is invalid, such as being on an unmapped drive.
/// The caller does not have the required permission.
// Token: 0x06001613 RID: 5651 RVA: 0x00055074 File Offset: 0x00053274
public FileInfo[] GetFiles(string searchPattern, SearchOption searchOption)
{
if (searchOption == SearchOption.TopDirectoryOnly)
{
return this.GetFiles(searchPattern);
}
if (searchOption != SearchOption.AllDirectories)
{
string text = Locale.GetText("Invalid enum value '{0}' for '{1}'.", new object[] { searchOption, "SearchOption" });
throw new ArgumentOutOfRangeException("searchOption", text);
}
ArrayList arrayList = new ArrayList();
int filesSubdirs = this.GetFilesSubdirs(arrayList, searchPattern);
int num = 0;
FileInfo[] array = new FileInfo[filesSubdirs];
foreach (object obj in arrayList)
{
FileInfo[] array2 = (FileInfo[])obj;
array2.CopyTo(array, num);
num += array2.Length;
}
return array;
}
// Token: 0x04000648 RID: 1608
private string current;
// Token: 0x04000649 RID: 1609
private string parent;
}
}