C# Класс Nexus.Client.Util.FileUtil

Utility functions to work with files.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
ClearAttributes ( DirectoryInfo p_difPath, bool p_booRecurse ) : void

Clears the attributes of the given directory.

This sets the directory's attributes to FileAttributes.Normal. This operation is optionally recursive.

ClearAttributes ( string p_strPath, bool p_booRecurse ) : void

Clears the attributes of the given path.

This sets the path's attributes to FileAttributes.Normal. This operation is optionally recursive.

ContainsInvalidPathChars ( string p_strPath ) : bool

Determines if the given path contains invalid characters.

Copy ( TxFileManager p_tfmFileManager, string p_strSource, string p_strDestination, bool>.Func p_fncCopyCallback ) : bool

Copies the source to the destination.

If the source is a directory, it is copied recursively.

Copy ( string p_strSource, string p_strDestination, bool>.Func p_fncCopyCallback ) : bool

Copies the source to the destination.

If the source is a directory, it is copied recursively.

CreateTempDirectory ( ) : string

Creates a temporary directory.

ForceDelete ( string p_strPath ) : void

Forces deletion of the given path.

This method is recursive if the given path is a directory. This method will clear read only/system attributes if required to delete the path.

IsDrivePath ( string p_strPath ) : bool

Determines whether or not the given path represents a drive.

IsValidPath ( string p_strPath ) : bool

Determines if the given path is valid.

Move ( string p_strFrom, string p_strTo, bool p_booOverwrite ) : void

Moves the specified file to the specified path, optionally overwritting any existing file.

NormalizePath ( string p_strPath ) : string

Normalizes the given path.

This removes multiple consecutive path separators and makes sure all path separators are Path.DirectorySeparatorChar.

RelativizePath ( string p_strRoot, string p_strPath ) : string

Generates a path that is relative to another path.

StripInvalidPathChars ( string p_strPath ) : string

Removes all invalid characters from the given path.

WriteAllBytes ( string p_strPath, byte p_bteData ) : void

Writes the given data to the specified file.

If the specified file exists, it will be overwritten. If the specified file does not exist, it is created. If the directory containing the specified file does not exist, it is created.

WriteAllText ( string p_strPath, string p_strData ) : void

Writes the given data to the specified file.

If the specified file exists, it will be overwritten. If the specified file does not exist, it is created. If the directory containing the specified file does not exist, it is created.

Защищенные методы

Метод Описание
CreateTempDirectory ( string p_strBasePath ) : string

Creates a temporary directory rooted at the given path.

Описание методов

ClearAttributes() публичный статический Метод

Clears the attributes of the given directory.
This sets the directory's attributes to FileAttributes.Normal. This operation is optionally recursive.
public static ClearAttributes ( DirectoryInfo p_difPath, bool p_booRecurse ) : void
p_difPath System.IO.DirectoryInfo The directory whose attributes are to be cleared.
p_booRecurse bool Whether or not to clear the attributes on all children files and folers.
Результат void

ClearAttributes() публичный статический Метод

Clears the attributes of the given path.
This sets the path's attributes to FileAttributes.Normal. This operation is optionally recursive.
public static ClearAttributes ( string p_strPath, bool p_booRecurse ) : void
p_strPath string The path whose attributes are to be cleared.
p_booRecurse bool Whether or not to clear the attributes on all children files and folers.
Результат void

ContainsInvalidPathChars() публичный статический Метод

Determines if the given path contains invalid characters.
public static ContainsInvalidPathChars ( string p_strPath ) : bool
p_strPath string The path to examine.
Результат bool

Copy() публичный статический Метод

Copies the source to the destination.
If the source is a directory, it is copied recursively.
public static Copy ( TxFileManager p_tfmFileManager, string p_strSource, string p_strDestination, bool>.Func p_fncCopyCallback ) : bool
p_tfmFileManager ChinhDo.Transactions.TxFileManager The transactional file manager to use to copy the files.
p_strSource string The path from which to copy.
p_strDestination string The path to which to copy.
p_fncCopyCallback bool>.Func A callback method that notifies the caller when a file has been copied, /// and provides the opportunity to cancel the copy operation.
Результат bool

Copy() публичный статический Метод

Copies the source to the destination.
If the source is a directory, it is copied recursively.
public static Copy ( string p_strSource, string p_strDestination, bool>.Func p_fncCopyCallback ) : bool
p_strSource string The path from which to copy.
p_strDestination string The path to which to copy.
p_fncCopyCallback bool>.Func A callback method that notifies the caller when a file has been copied, /// and provides the opportunity to cancel the copy operation.
Результат bool

CreateTempDirectory() публичный Метод

Creates a temporary directory.
public CreateTempDirectory ( ) : string
Результат string

CreateTempDirectory() защищенный Метод

Creates a temporary directory rooted at the given path.
protected CreateTempDirectory ( string p_strBasePath ) : string
p_strBasePath string The path under which to create the temporary directory.
Результат string

ForceDelete() публичный статический Метод

Forces deletion of the given path.
This method is recursive if the given path is a directory. This method will clear read only/system attributes if required to delete the path.
public static ForceDelete ( string p_strPath ) : void
p_strPath string The path to delete.
Результат void

IsDrivePath() публичный статический Метод

Determines whether or not the given path represents a drive.
public static IsDrivePath ( string p_strPath ) : bool
p_strPath string The path for which it is to be determine whether it represents a drive.
Результат bool

IsValidPath() публичный статический Метод

Determines if the given path is valid.
public static IsValidPath ( string p_strPath ) : bool
p_strPath string The path to examine.
Результат bool

Move() публичный статический Метод

Moves the specified file to the specified path, optionally overwritting any existing file.
public static Move ( string p_strFrom, string p_strTo, bool p_booOverwrite ) : void
p_strFrom string The path to the file to move.
p_strTo string the path to which to move the file.
p_booOverwrite bool Whether to overwrite any file found at the destination.
Результат void

NormalizePath() публичный статический Метод

Normalizes the given path.
This removes multiple consecutive path separators and makes sure all path separators are Path.DirectorySeparatorChar.
public static NormalizePath ( string p_strPath ) : string
p_strPath string The path to normalize.
Результат string

RelativizePath() публичный статический Метод

Generates a path that is relative to another path.
Thrown if either parameter is null.
public static RelativizePath ( string p_strRoot, string p_strPath ) : string
p_strRoot string The root directory with respect to which the path will be made relative.
p_strPath string The path to make relative.
Результат string

StripInvalidPathChars() публичный статический Метод

Removes all invalid characters from the given path.
public static StripInvalidPathChars ( string p_strPath ) : string
p_strPath string The path to clean.
Результат string

WriteAllBytes() публичный статический Метод

Writes the given data to the specified file.
If the specified file exists, it will be overwritten. If the specified file does not exist, it is created. If the directory containing the specified file does not exist, it is created.
public static WriteAllBytes ( string p_strPath, byte p_bteData ) : void
p_strPath string The path to which to write the given data.
p_bteData byte The data to write to the file.
Результат void

WriteAllText() публичный статический Метод

Writes the given data to the specified file.
If the specified file exists, it will be overwritten. If the specified file does not exist, it is created. If the directory containing the specified file does not exist, it is created.
public static WriteAllText ( string p_strPath, string p_strData ) : void
p_strPath string The path to which to write the given text.
p_strData string The text to write to the file.
Результат void