C# Класс Duality.PathHelper

Provides helper methods for handling Paths.
Показать файл Открыть проект

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

Метод Описание
CopyDirectory ( string sourcePath, string targetPath, bool overwrite = false, Predicate filter = null ) : bool

Deep-Copies the source directory to the target path.

FilesEqual ( string filePathA, string filePathB ) : bool

Determines whether the contents of two files are completely equal.

GetFileHash ( string filePath ) : int

Calculates a hash value from the full (byte by byte) content of a file.

GetFreePath ( string pathBase, string pathExt ) : string

Returns a path that isn't taken yet.

GetMutualDirectory ( string path, string path2 ) : string

Returns a mutual base path of two different paths.

GetValidFileName ( string fileName ) : string

Takes a string that is supposed to be a file name and converts it into an actually valid file name, replacing invalid characters by undercores.

IsPathLocatedIn ( string path, string baseDir ) : bool

Returns whether one path is a sub-path of another.

IsPathVisible ( string path ) : bool

Returns whether the specified file or directory is visible, i.e. not hidden.

MakeFilePathRelative ( string filePath, string relativeToDir = "." ) : string

Returns the relative path from one path to another.

Приватные методы

Метод Описание
IsPathValid ( string path ) : bool

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

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

Deep-Copies the source directory to the target path.
public static CopyDirectory ( string sourcePath, string targetPath, bool overwrite = false, Predicate filter = null ) : bool
sourcePath string
targetPath string
overwrite bool
filter Predicate
Результат bool

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

Determines whether the contents of two files are completely equal.
public static FilesEqual ( string filePathA, string filePathB ) : bool
filePathA string
filePathB string
Результат bool

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

Calculates a hash value from the full (byte by byte) content of a file.
public static GetFileHash ( string filePath ) : int
filePath string
Результат int

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

Returns a path that isn't taken yet.
public static GetFreePath ( string pathBase, string pathExt ) : string
pathBase string The path to use as base for finding a available path.
pathExt string The (file) extension to add to the new path.
Результат string

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

Returns a mutual base path of two different paths.
public static GetMutualDirectory ( string path, string path2 ) : string
path string The first path.
path2 string The second path.
Результат string

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

Takes a string that is supposed to be a file name and converts it into an actually valid file name, replacing invalid characters by undercores.
public static GetValidFileName ( string fileName ) : string
fileName string A string that is supposed to be a file name.
Результат string

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

Returns whether one path is a sub-path of another.
public static IsPathLocatedIn ( string path, string baseDir ) : bool
path string The supposed sub-path.
baseDir string The (directory) path in which the supposed sub-path might be located in.
Результат bool

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

Returns whether the specified file or directory is visible, i.e. not hidden.
public static IsPathVisible ( string path ) : bool
path string
Результат bool

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

Returns the relative path from one path to another.
public static MakeFilePathRelative ( string filePath, string relativeToDir = "." ) : string
filePath string The path to make relative.
relativeToDir string The path to make it relative to.
Результат string