C# Class DotNetIO.Internal.LongPathFile

Provides static methods for creating, copying, deleting, moving, and opening of files with long paths, that is, paths that exceed 259 characters.
显示文件 Open project: DotNetIO/DotNetIO

Public Methods

Method Description
Copy ( Path sourcePath, Path destinationPath, bool overwrite ) : void

Copies the specified file to a specified new file, indicating whether to overwrite an existing file.

Delete ( Path path ) : void

Deletes the specified file.

Exists ( Path path ) : bool

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

Note that this method will return false if any error occurs while trying to determine if the specified file exists. This includes situations that would normally result in thrown exceptions including (but not limited to); passing in a file 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 file.

Move ( Path sourcePath, Path destinationPath ) : void

Moves the specified file to a new location.

Open ( Path path, FileMode mode, FileAccess access, FileShare share ) : FileStream

Opens the specified file.

Open ( Path path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options ) : FileStream

Opens the specified file.

Private Methods

Method Description
GetFileHandle ( Path path, FileMode mode, FileAccess access, FileShare share, FileOptions options ) : SafeFileHandle
GetFileHandle ( string normalizedPath, FileMode mode, FileAccess access, FileShare share, FileOptions options ) : SafeFileHandle

Method Details

Copy() public static method

Copies the specified file to a specified new file, indicating whether to overwrite an existing file.
/// and/or is /// . /// /// and/or is /// an empty string (""), contains only white space, or contains one or more /// invalid characters as defined in . /// /// -or- /// /// and/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. /// /// and/or /// exceeds the system-defined maximum length. For example, on Windows-based platforms, /// paths must not exceed 32,000 characters. /// /// could not be found. /// /// One or more directories in and/or /// could not be found. /// /// The caller does not have the required access permissions. /// /// -or- /// /// is true and refers to a /// file that is read-only. /// /// is false and refers to /// a file that already exists. /// /// -or- /// /// and/or is a /// directory. /// /// -or- /// /// is true and refers to /// a file that already exists and is in use. /// /// -or- /// /// refers to a file that is in use. /// /// -or- /// /// and/or specifies /// a device that is not ready. ///
public static Copy ( Path sourcePath, Path destinationPath, bool overwrite ) : void
sourcePath System.IO.Path /// A containing the path of the file to copy. ///
destinationPath System.IO.Path /// A containing the new path of the file. ///
overwrite bool /// if should be overwritten /// if it refers to an existing file, otherwise, . ///
return void

Delete() public static method

Deletes the specified file.
/// 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. /// /// One or more directories in could not be found. /// /// The caller does not have the required access permissions. /// /// -or- /// /// refers to a file that is read-only. /// /// -or- /// /// is a directory. /// /// refers to a file 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 file to delete. ///
return void

Exists() public static method

Returns a value indicating whether the specified path refers to an existing file.
Note that this method will return false if any error occurs while trying to determine if the specified file exists. This includes situations that would normally result in thrown exceptions including (but not limited to); passing in a file 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 file.
public static Exists ( Path path ) : bool
path System.IO.Path /// A containing the path to check. ///
return bool

Move() public static method

Moves the specified file to a new location.
/// and/or is /// . /// /// and/or is /// an empty string (""), contains only white space, or contains one or more /// invalid characters as defined in . /// /// -or- /// /// and/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. /// /// and/or /// exceeds the system-defined maximum length. For example, on Windows-based platforms, /// paths must not exceed 32,000 characters. /// /// could not be found. /// /// One or more directories in and/or /// could not be found. /// /// The caller does not have the required access permissions. /// /// refers to a file that already exists. /// /// -or- /// /// and/or is a /// directory. /// /// -or- /// /// refers to a file that is in use. /// /// -or- /// /// and/or specifies /// a device that is not ready. ///
public static Move ( Path sourcePath, Path destinationPath ) : void
sourcePath System.IO.Path /// A containing the path of the file to move. ///
destinationPath System.IO.Path /// A containing the new path of the file. ///
return void

Open() public static method

Opens the specified file.
/// 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. /// /// One or more directories in could not be found. /// /// The caller does not have the required access permissions. /// /// -or- /// /// refers to a file that is read-only and /// is not . /// /// -or- /// /// is a directory. /// /// refers to a file that is in use. /// /// -or- /// /// specifies a device that is not ready. ///
public static Open ( Path path, FileMode mode, FileAccess access, FileShare share ) : FileStream
path System.IO.Path /// A containing the path of the file to open. ///
mode FileMode /// One of the values that specifies whether a file is created /// if one does not exist, and determines whether the contents of existing files are /// retained or overwritten. ///
access FileAccess /// One of the value that specifies the operations that can be /// performed on the file. ///
share FileShare /// One of the values specifying the type of access other threads /// have to the file. ///
return System.IO.FileStream

Open() public static method

Opens the specified file.
/// 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. /// /// is less than 0. /// /// exceeds the system-defined maximum length. /// For example, on Windows-based platforms, paths must not exceed /// 32,000 characters. /// /// One or more directories in could not be found. /// /// The caller does not have the required access permissions. /// /// -or- /// /// refers to a file that is read-only and /// is not . /// /// -or- /// /// is a directory. /// /// refers to a file that is in use. /// /// -or- /// /// specifies a device that is not ready. ///
public static Open ( Path path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options ) : FileStream
path System.IO.Path /// A containing the path of the file to open. ///
mode FileMode /// One of the values that specifies whether a file is created /// if one does not exist, and determines whether the contents of existing files are /// retained or overwritten. ///
access FileAccess /// One of the value that specifies the operations that can be /// performed on the file. ///
share FileShare /// One of the values specifying the type of access other threads /// have to the file. ///
bufferSize int /// An containing the number of bytes to buffer for reads and writes /// to the file, or 0 to specifiy the default buffer size, 1024. ///
options FileOptions /// One or more of the values that describes how to create or /// overwrite the file. ///
return System.IO.FileStream