16 private string[] demandDir;
26 [SecuritySafeCritical]
29 Directory.CheckPermissions(
string.Empty,
FullPath, checkHost:
true, FileSecurityStateAccess.PathDiscovery);
34 internal override string UnsafeGetFullName
39 Directory.CheckPermissions(
string.Empty,
FullPath, checkHost:
false, FileSecurityStateAccess.PathDiscovery);
49 [SecuritySafeCritical]
58 if (directoryName ==
null)
63 Directory.CheckPermissions(
string.Empty, directoryInfo.
FullPath, checkHost:
true, FileSecurityStateAccess.Read | FileSecurityStateAccess.PathDiscovery);
71 public override bool Exists 73 [SecuritySafeCritical]
78 if (_dataInitialised == -1)
82 if (_dataInitialised != 0)
86 return _data.fileAttributes != -1 && (_data.fileAttributes & 0x10) != 0;
100 [SecuritySafeCritical]
104 string text =
FullPath.Substring(0, rootLength);
105 string fullPath =
Directory.GetDemandDir(text, thisDirOnly:
true);
119 [SecuritySafeCritical]
126 Init(path, checkHost:
true);
130 private void Init(
string path,
bool checkHost)
132 if (path.Length == 2 && path[1] ==
':')
140 string text =
FullPath =
Directory.GetFullPathAndCheckPermissions(path, checkHost);
153 : base(info, context)
195 [SecuritySafeCritical]
198 return CreateSubdirectoryHelper(path, directorySecurity);
202 private DirectoryInfo CreateSubdirectoryHelper(
string path,
object directorySecurity)
205 string fullPathInternal =
Path.GetFullPathInternal(path2);
208 string displayablePath = __Error.GetDisplayablePath(base.DisplayPath, isInvalidPath:
false);
211 string fullPath =
Directory.GetDemandDir(fullPathInternal, thisDirOnly:
true);
213 Directory.InternalCreateDirectory(fullPathInternal, path, directorySecurity);
293 if (searchPattern ==
null)
297 return InternalGetFiles(searchPattern,
SearchOption.TopDirectoryOnly);
314 if (searchPattern ==
null)
318 if (searchOption != 0 && searchOption !=
SearchOption.AllDirectories)
322 return InternalGetFiles(searchPattern, searchOption);
329 return list.ToArray();
337 return InternalGetFiles(
"*",
SearchOption.TopDirectoryOnly);
347 return InternalGetDirectories(
"*",
SearchOption.TopDirectoryOnly);
361 if (searchPattern ==
null)
365 return InternalGetFileSystemInfos(searchPattern,
SearchOption.TopDirectoryOnly);
382 if (searchPattern ==
null)
386 if (searchOption != 0 && searchOption !=
SearchOption.AllDirectories)
390 return InternalGetFileSystemInfos(searchPattern, searchOption);
397 return list.ToArray();
405 return InternalGetFileSystemInfos(
"*",
SearchOption.TopDirectoryOnly);
419 if (searchPattern ==
null)
423 return InternalGetDirectories(searchPattern,
SearchOption.TopDirectoryOnly);
440 if (searchPattern ==
null)
444 if (searchOption != 0 && searchOption !=
SearchOption.AllDirectories)
448 return InternalGetDirectories(searchPattern, searchOption);
455 return list.ToArray();
464 return InternalEnumerateDirectories(
"*",
SearchOption.TopDirectoryOnly);
476 if (searchPattern ==
null)
480 return InternalEnumerateDirectories(searchPattern,
SearchOption.TopDirectoryOnly);
495 if (searchPattern ==
null)
499 if (searchOption != 0 && searchOption !=
SearchOption.AllDirectories)
503 return InternalEnumerateDirectories(searchPattern, searchOption);
508 return FileSystemEnumerableFactory.CreateDirectoryInfoIterator(
FullPath,
OriginalPath, searchPattern, searchOption);
517 return InternalEnumerateFiles(
"*",
SearchOption.TopDirectoryOnly);
529 if (searchPattern ==
null)
533 return InternalEnumerateFiles(searchPattern,
SearchOption.TopDirectoryOnly);
548 if (searchPattern ==
null)
552 if (searchOption != 0 && searchOption !=
SearchOption.AllDirectories)
556 return InternalEnumerateFiles(searchPattern, searchOption);
561 return FileSystemEnumerableFactory.CreateFileInfoIterator(
FullPath,
OriginalPath, searchPattern, searchOption);
570 return InternalEnumerateFileSystemInfos(
"*",
SearchOption.TopDirectoryOnly);
582 if (searchPattern ==
null)
586 return InternalEnumerateFileSystemInfos(searchPattern,
SearchOption.TopDirectoryOnly);
601 if (searchPattern ==
null)
605 if (searchOption != 0 && searchOption !=
SearchOption.AllDirectories)
609 return InternalEnumerateFileSystemInfos(searchPattern, searchOption);
614 return FileSystemEnumerableFactory.CreateFileSystemInfoIterator(
FullPath,
OriginalPath, searchPattern, searchOption);
627 [SecuritySafeCritical]
630 if (destDirName ==
null)
634 if (destDirName.Length == 0)
638 Directory.CheckPermissions(base.DisplayPath,
FullPath, checkHost:
true, FileSecurityStateAccess.Read | FileSecurityStateAccess.Write);
639 string text =
Path.GetFullPathInternal(destDirName);
644 Directory.CheckPermissions(destDirName, text, checkHost:
true, FileSecurityStateAccess.Read | FileSecurityStateAccess.Write);
652 if (
string.Compare(pathRoot, pathRoot2,
StringComparison.OrdinalIgnoreCase) != 0)
656 if (!Win32Native.MoveFile(
FullPath, destDirName))
662 __Error.WinIOError(num, base.DisplayPath);
666 throw new IOException(
Environment.GetResourceString(
"UnauthorizedAccess_IODenied_Path", base.DisplayPath));
668 __Error.WinIOError(num,
string.Empty);
673 _dataInitialised = -1;
681 [SecuritySafeCritical]
694 [SecuritySafeCritical]
704 return base.DisplayPath;
707 private static string GetDisplayName(
string originalPath,
string fullPath)
710 if (originalPath.Length == 2 && originalPath[1] ==
':')
717 private static string GetDirName(
string fullPath)
720 if (fullPath.Length > 3)
722 string path = fullPath;
723 if (fullPath.EndsWith(Path.DirectorySeparatorChar))
725 path = fullPath.Substring(0, fullPath.Length - 1);
727 return Path.GetFileName(path);
FileSystemInfo [] GetFileSystemInfos(string searchPattern)
Retrieves an array of strongly typed T:System.IO.FileSystemInfo objects representing the files and su...
Exposes instance methods for creating, moving, and enumerating through directories and subdirectories...
static void SetAccessControl(string path, DirectorySecurity directorySecurity)
Applies access control list (ACL) entries described by a T:System.Security.AccessControl....
IEnumerable< DirectoryInfo > EnumerateDirectories(string searchPattern)
Returns an enumerable collection of directory information that matches a specified search pattern.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
FileIOPermissionAccess
Specifies the type of file access requested.
FileInfo [] GetFiles(string searchPattern, SearchOption searchOption)
Returns a file list from the current directory matching the given search pattern and using a value to...
IEnumerable< FileInfo > EnumerateFiles(string searchPattern, SearchOption searchOption)
Returns an enumerable collection of file information that matches a specified search pattern and sear...
static DirectorySecurity GetAccessControl(string path)
Gets a T:System.Security.AccessControl.DirectorySecurity object that encapsulates the access control ...
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
DirectorySecurity GetAccessControl(AccessControlSections includeSections)
Gets a T:System.Security.AccessControl.DirectorySecurity object that encapsulates the specified type ...
IEnumerable< FileSystemInfo > EnumerateFileSystemInfos()
Returns an enumerable collection of file system information in the current directory.
IEnumerable< FileInfo > EnumerateFiles()
Returns an enumerable collection of file information in the current directory.
void Create(DirectorySecurity directorySecurity)
Creates a directory using a T:System.Security.AccessControl.DirectorySecurity object.
IEnumerable< FileSystemInfo > EnumerateFileSystemInfos(string searchPattern)
Returns an enumerable collection of file system information that matches a specified search pattern.
override string FullName
Gets the full path of the directory.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
IEnumerable< DirectoryInfo > EnumerateDirectories(string searchPattern, SearchOption searchOption)
Returns an enumerable collection of directory information that matches a specified search pattern and...
static string GetPathRoot(string path)
Gets the root directory information of the specified path.
Exposes the enumerator, which supports a simple iteration over a collection of a specified type....
static readonly char DirectorySeparatorChar
Provides a platform-specific character used to separate directory levels in a path string that reflec...
Describes the source and destination of a given serialized stream, and provides an additional caller-...
SearchOption
Specifies whether to search the current directory, or the current directory and all subdirectories.
DirectoryInfo CreateSubdirectory(string path, DirectorySecurity directorySecurity)
Creates a subdirectory or subdirectories on the specified path with the specified security....
Represents the access control and audit security for a directory. This class cannot be inherited.
IEnumerable< DirectoryInfo > EnumerateDirectories()
Returns an enumerable collection of directory information in the current directory.
void Delete(bool recursive)
Deletes this instance of a T:System.IO.DirectoryInfo, specifying whether to delete subdirectories and...
Provides information about, and means to manipulate, the current environment and platform....
FileSystemInfo [] GetFileSystemInfos()
Returns an array of strongly typed T:System.IO.FileSystemInfo entries representing all the files and ...
Provides properties and instance methods for the creation, copying, deletion, moving,...
static void Delete(string path)
Deletes an empty directory from a specified path.
override string Name
Gets the name of this T:System.IO.DirectoryInfo instance.
Exposes static methods for creating, moving, and enumerating through directories and subdirectories....
The exception that is thrown when an I/O error occurs.
DirectoryInfo Root
Gets the root portion of the directory.
DirectoryInfo [] GetDirectories(string searchPattern, SearchOption searchOption)
Returns an array of directories in the current T:System.IO.DirectoryInfo matching the given search cr...
Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks,...
DirectoryInfo [] GetDirectories()
Returns the subdirectories of the current directory.
DirectoryInfo CreateSubdirectory(string path)
Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to...
DirectoryInfo Parent
Gets the parent directory of a specified subdirectory.
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
FileInfo [] GetFiles(string searchPattern)
Returns a file list from the current directory matching the given search pattern.
The exception that is thrown when one of the arguments provided to a method is not valid.
IEnumerable< FileInfo > EnumerateFiles(string searchPattern)
Returns an enumerable collection of file information that matches a search pattern.
FileInfo [] GetFiles()
Returns a file list from the current directory.
DirectoryInfo [] GetDirectories(string searchPattern)
Returns an array of directories in the current T:System.IO.DirectoryInfo matching the given search cr...
override string ToString()
Returns the original path that was passed by the user.
DirectorySecurity GetAccessControl()
Gets a T:System.Security.AccessControl.DirectorySecurity object that encapsulates the access control ...
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
override void Delete()
Deletes this T:System.IO.DirectoryInfo if it is empty.
void Create()
Creates a directory.
FileSystemInfo [] GetFileSystemInfos(string searchPattern, SearchOption searchOption)
Retrieves an array of T:System.IO.FileSystemInfo objects that represent the files and subdirectories ...
override bool Exists
Gets a value indicating whether the directory exists.
void MoveTo(string destDirName)
Moves a T:System.IO.DirectoryInfo instance and its contents to a new path.
void Refresh()
Refreshes the state of the object.
Specifies that the class can be serialized.
DirectoryInfo(string path)
Initializes a new instance of the T:System.IO.DirectoryInfo class on the specified path.
void SetAccessControl(DirectorySecurity directorySecurity)
Applies access control list (ACL) entries described by a T:System.Security.AccessControl....
static string GetDirectoryName(string path)
Returns the directory information for the specified path string.
IEnumerable< FileSystemInfo > EnumerateFileSystemInfos(string searchPattern, SearchOption searchOption)
Returns an enumerable collection of file system information that matches a specified search pattern a...
Controls the ability to access files and folders. This class cannot be inherited.
static int GetLastWin32Error()
Returns the error code returned by the last unmanaged function that was called using platform invoke ...
Provides the base class for both T:System.IO.FileInfo and T:System.IO.DirectoryInfo objects.
string FullPath
Represents the fully qualified path of the directory or file.
AccessControlSections
Specifies which sections of a security descriptor to save or load.
The P:System.Uri.LocalPath data.
Performs operations on T:System.String instances that contain file or directory path information....
string OriginalPath
The path originally specified by the user, whether relative or absolute.