C# Class DotNetIO.Internal.LongPathDirectory

Provides methods for creating, deleting, moving and enumerating directories and subdirectories with long paths, that is, paths that exceed 259 characters.
Mostra file Open project: DotNetIO/DotNetIO Class Usage Examples

Public Methods

Method Description
Create ( Path path ) : void

Creates the specified directory.

Note: Unlike System.IO.Directory.CreateDirectory(System.String), this method only creates the last directory in path.

Delete ( Path path ) : void

Deletes the specified empty directory.

Delete ( Path path, bool recursively ) : void

Deletes files from the given path.

EnumerateDirectories ( Path path ) : IEnumerable

Returns a enumerable containing the directory names of the specified directory.

EnumerateDirectories ( Path path, string searchPattern ) : IEnumerable

Returns a enumerable containing the directory names of the specified directory that match the specified search pattern.

EnumerateFileSystemEntries ( Path path ) : IEnumerable

Returns a enumerable containing the file and directory names of the specified directory.

EnumerateFileSystemEntries ( Path path, string searchPattern ) : IEnumerable

Returns a enumerable containing the file and directory names of the specified directory that match the specified search pattern.

EnumerateFiles ( Path path ) : IEnumerable

Returns a enumerable containing the file names of the specified directory.

EnumerateFiles ( Path path, string searchPattern ) : IEnumerable

Returns a enumerable containing the file names of the specified directory that match the specified search pattern.

Exists ( Path path ) : bool

Returns a value indicating whether the specified path refers to an existing directory.

Note that this method will return false if any error occurs while trying to determine if the specified directory exists. This includes situations that would normally result in thrown exceptions including (but not limited to); passing in a directory name with invalid or too many characters, an I/O error such as a failing or missing disk, or if the caller does not have Windows or Code Access Security (CAS) permissions to to read the directory.

Move ( Path sourcePath, Path targetPath ) : void

Private Methods

Method Description
BeginFind ( string normalizedPathWithSearchPattern, WIN32_FIND_DATA &findData ) : SafeFindHandle
EnumerateFileSystemEntries ( Path path, string searchPattern, bool includeDirectories, bool includeFiles ) : IEnumerable
EnumerateFileSystemIterator ( string normalizedPath, string normalizedSearchPattern, bool includeDirectories, bool includeFiles ) : IEnumerable
IsCurrentOrParentDirectory ( string directoryName ) : bool
IsDirectory ( FileAttributes attributes ) : bool

Method Details

Create() public static method

Creates the specified directory.
Note: Unlike System.IO.Directory.CreateDirectory(System.String), this method only creates the last directory in path.
/// is . /// /// is an empty string (""), contains only white /// space, or contains one or more invalid characters as defined in /// . /// /// -or- /// /// contains one or more components that exceed /// the drive-defined maximum length. For example, on Windows-based /// platforms, components must not exceed 255 characters. /// /// exceeds the system-defined maximum length. /// For example, on Windows-based platforms, paths must not exceed /// 32,000 characters. /// /// contains one or more directories that could not be /// found. /// /// The caller does not have the required access permissions. /// /// is a file. /// /// -or- /// /// specifies a device that is not ready. ///
public static Create ( Path path ) : void
path System.IO.Path /// A containing the path of the directory to create. ///
return void

Delete() public static method

Deletes the specified empty directory.
/// is . /// /// is an empty string (""), contains only white /// space, or contains one or more invalid characters as defined in /// . /// /// -or- /// /// contains one or more components that exceed /// the drive-defined maximum length. For example, on Windows-based /// platforms, components must not exceed 255 characters. /// /// exceeds the system-defined maximum length. /// For example, on Windows-based platforms, paths must not exceed /// 32,000 characters. /// /// could not be found. /// /// The caller does not have the required access permissions. /// /// -or- /// /// refers to a directory that is read-only. /// /// is a file. /// /// -or- /// /// refers to a directory that is not empty. /// /// -or- /// /// refers to a directory that is in use. /// /// -or- /// /// specifies a device that is not ready. ///
public static Delete ( Path path ) : void
path System.IO.Path /// A containing the path of the directory to delete. ///
return void

Delete() public static method

Deletes files from the given path.
/// is . /// /// is an empty string (""), contains only white /// space, or contains one or more invalid characters as defined in /// . /// /// -or- /// /// contains one or more components that exceed /// the drive-defined maximum length. For example, on Windows-based /// platforms, components must not exceed 255 characters. /// /// exceeds the system-defined maximum length. /// For example, on Windows-based platforms, paths must not exceed /// 32,000 characters. /// /// could not be found. /// /// The caller does not have the required access permissions. /// /// -or- /// /// refers to a directory that is read-only. /// /// is a file. /// /// -or- /// /// refers to a directory that is not empty. /// /// -or- /// /// refers to a directory that is in use. /// /// -or- /// /// specifies a device that is not ready. ///
public static Delete ( Path path, bool recursively ) : void
path System.IO.Path The path to delete files from.
recursively bool Whether to recurse through the directory and find all child directories and files /// and delete those
return void

EnumerateDirectories() public static method

Returns a enumerable containing the directory names of the specified directory.
/// is . /// /// is an empty string (""), contains only white /// space, or contains one or more invalid characters as defined in /// . /// /// -or- /// /// contains one or more components that exceed /// the drive-defined maximum length. For example, on Windows-based /// platforms, components must not exceed 255 characters. /// /// exceeds the system-defined maximum length. /// For example, on Windows-based platforms, paths must not exceed /// 32,000 characters. /// /// contains one or more directories that could not be /// found. /// /// The caller does not have the required access permissions. /// /// is a file. /// /// -or- /// /// specifies a device that is not ready. ///
public static EnumerateDirectories ( Path path ) : IEnumerable
path System.IO.Path /// A containing the path of the directory to search. ///
return IEnumerable

EnumerateDirectories() public static method

Returns a enumerable containing the directory names of the specified directory that match the specified search pattern.
/// is . /// /// is an empty string (""), contains only white /// space, or contains one or more invalid characters as defined in /// . /// /// -or- /// /// contains one or more components that exceed /// the drive-defined maximum length. For example, on Windows-based /// platforms, components must not exceed 255 characters. /// /// exceeds the system-defined maximum length. /// For example, on Windows-based platforms, paths must not exceed /// 32,000 characters. /// /// contains one or more directories that could not be /// found. /// /// The caller does not have the required access permissions. /// /// is a file. /// /// -or- /// /// specifies a device that is not ready. ///
public static EnumerateDirectories ( Path path, string searchPattern ) : IEnumerable
path System.IO.Path /// A containing the path of the directory to search. ///
searchPattern string /// A containing search pattern to match against the names of the /// directories in , otherwise, or an empty /// string ("") to use the default search pattern, "*". ///
return IEnumerable

EnumerateFileSystemEntries() public static method

Returns a enumerable containing the file and directory names of the specified directory.
/// is . /// /// is an empty string (""), contains only white /// space, or contains one or more invalid characters as defined in /// . /// /// -or- /// /// contains one or more components that exceed /// the drive-defined maximum length. For example, on Windows-based /// platforms, components must not exceed 255 characters. /// /// exceeds the system-defined maximum length. /// For example, on Windows-based platforms, paths must not exceed /// 32,000 characters. /// /// contains one or more directories that could not be /// found. /// /// The caller does not have the required access permissions. /// /// is a file. /// /// -or- /// /// specifies a device that is not ready. ///
public static EnumerateFileSystemEntries ( Path path ) : IEnumerable
path System.IO.Path /// A containing the path of the directory to search. ///
return IEnumerable

EnumerateFileSystemEntries() public static method

Returns a enumerable containing the file and directory names of the specified directory that match the specified search pattern.
/// is . /// /// is an empty string (""), contains only white /// space, or contains one or more invalid characters as defined in /// . /// /// -or- /// /// contains one or more components that exceed /// the drive-defined maximum length. For example, on Windows-based /// platforms, components must not exceed 255 characters. /// /// exceeds the system-defined maximum length. /// For example, on Windows-based platforms, paths must not exceed /// 32,000 characters. /// /// contains one or more directories that could not be /// found. /// /// The caller does not have the required access permissions. /// /// is a file. /// /// -or- /// /// specifies a device that is not ready. ///
public static EnumerateFileSystemEntries ( Path path, string searchPattern ) : IEnumerable
path System.IO.Path /// A containing the path of the directory to search. ///
searchPattern string /// A containing search pattern to match against the names of the /// files and directories in , otherwise, /// or an empty string ("") to use the default search pattern, "*". ///
return IEnumerable

EnumerateFiles() public static method

Returns a enumerable containing the file names of the specified directory.
/// is . /// /// is an empty string (""), contains only white /// space, or contains one or more invalid characters as defined in /// . /// /// -or- /// /// contains one or more components that exceed /// the drive-defined maximum length. For example, on Windows-based /// platforms, components must not exceed 255 characters. /// /// exceeds the system-defined maximum length. /// For example, on Windows-based platforms, paths must not exceed /// 32,000 characters. /// /// contains one or more directories that could not be /// found. /// /// The caller does not have the required access permissions. /// /// is a file. /// /// -or- /// /// specifies a device that is not ready. ///
public static EnumerateFiles ( Path path ) : IEnumerable
path System.IO.Path /// A containing the path of the directory to search. ///
return IEnumerable

EnumerateFiles() public static method

Returns a enumerable containing the file names of the specified directory that match the specified search pattern.
/// is . /// /// is an empty string (""), contains only white /// space, or contains one or more invalid characters as defined in /// . /// /// -or- /// /// contains one or more components that exceed /// the drive-defined maximum length. For example, on Windows-based /// platforms, components must not exceed 255 characters. /// /// exceeds the system-defined maximum length. /// For example, on Windows-based platforms, paths must not exceed /// 32,000 characters. /// /// contains one or more directories that could not be /// found. /// /// The caller does not have the required access permissions. /// /// is a file. /// /// -or- /// /// specifies a device that is not ready. ///
public static EnumerateFiles ( Path path, string searchPattern ) : IEnumerable
path System.IO.Path /// A containing the path of the directory to search. ///
searchPattern string /// A containing search pattern to match against the names of the /// files in , otherwise, or an empty /// string ("") to use the default search pattern, "*". ///
return IEnumerable

Exists() public static method

Returns a value indicating whether the specified path refers to an existing directory.
Note that this method will return false if any error occurs while trying to determine if the specified directory exists. This includes situations that would normally result in thrown exceptions including (but not limited to); passing in a directory name with invalid or too many characters, an I/O error such as a failing or missing disk, or if the caller does not have Windows or Code Access Security (CAS) permissions to to read the directory.
public static Exists ( Path path ) : bool
path System.IO.Path /// A containing the path to check. ///
return bool

Move() public static method

public static Move ( Path sourcePath, Path targetPath ) : void
sourcePath System.IO.Path
targetPath System.IO.Path
return void