C# Класс CoreTechs.Common.FileSystemExtensions

Показать файл Открыть проект

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

Метод Описание
AreSame ( this a, DirectoryInfo b ) : bool
AreSame ( this a, FileInfo b ) : bool
AttemptOpen ( this file, FileAccess fileAccess = FileAccess.ReadWrite, FileShare fileShare = FileShare.None ) : Attempt

Attempts to open a file. Immediately closes the file if successful. Swallows (but returns) any exception encountered while trying to open the file.

ComputeFileHash ( this fileInfo, HashAlgorithm algorithm = null ) : string
ComputeHash ( this stream, HashAlgorithm algorithm = null ) : byte[]
Contains ( this dir, FileSystemInfo other ) : bool

Determines if the directory contains the other directory or file at any depth.

ContainsDirectly ( this dir, FileSystemInfo other ) : bool

Determines if the directory directly contains the other directory or file.

ConvertToString ( this bytes ) : string
CreateFileSystemInfoFromPath ( this path ) : FileSystemInfo
EnsureExists ( this dir ) : DirectoryInfo
EnumerateBytes ( this file ) : IEnumerable
EnumeratePathDownFromRoot ( this source ) : IEnumerable

Yields each part of the path, ordered from the root to the item.

EnumeratePathUpToRoot ( this source ) : IEnumerable

Yields each part of the path, ordered from the item to the root.

GetFile ( this directory, string file ) : FileInfo
GetParentDirectory ( this fileSystemInfo ) : DirectoryInfo
GetPath ( this specialFolder, Environment option = Environment.SpecialFolderOption.None ) : string
GetRelativePathFrom ( this to, FileSystemInfo from ) : string
GetRelativePathTo ( this from, FileSystemInfo to ) : string
GetSubDirectory ( this directory ) : DirectoryInfo
GetUnchangedFiles ( this source, System.TimeSpan interval, CancellationToken cancellationToken = default(CancellationToken) ) : System.IO.FileInfo[]

Returns files that haven't changed over a period of time.

IsContainedDirectlyWithin ( this fileOrDirectory, DirectoryInfo otherDir ) : bool

Determines if the file or directory is contained directly within the the other directory.

IsContainedWithin ( this fileOrDirectory, DirectoryInfo otherDir ) : bool

Determines if the file or directory is contained within the the other directory at any depth.

IsDirectoryPath ( this path ) : bool
IsFilePath ( this path ) : bool
PollForAllFiles ( this di, System.TimeSpan interval, CancellationToken cancellationToken = default(CancellationToken) ) : System.IO.FileInfo[]

Checks and rechecks a directory and all sub-directories for files. Only returns files that haven't changed between checks.

PollForFiles ( this di, System.TimeSpan interval, string searchPattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly, CancellationToken cancellationToken = default(CancellationToken) ) : System.IO.FileInfo[]

Checks and rechecks a directory for files. Only returns files that haven't changed between checks.

WhereCanOpen ( this files ) : IEnumerable

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

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

public static AreSame ( this a, DirectoryInfo b ) : bool
a this
b System.IO.DirectoryInfo
Результат bool

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

public static AreSame ( this a, FileInfo b ) : bool
a this
b System.IO.FileInfo
Результат bool

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

Attempts to open a file. Immediately closes the file if successful. Swallows (but returns) any exception encountered while trying to open the file.
public static AttemptOpen ( this file, FileAccess fileAccess = FileAccess.ReadWrite, FileShare fileShare = FileShare.None ) : Attempt
file this The file to attempt to open.
fileAccess FileAccess The access required to open the file. Defaults to ReadWrite.
fileShare FileShare The access granted to others trying to manipulate the file. Defaults to none.
Результат Attempt

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

public static ComputeFileHash ( this fileInfo, HashAlgorithm algorithm = null ) : string
fileInfo this
algorithm System.Security.Cryptography.HashAlgorithm
Результат string

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

public static ComputeHash ( this stream, HashAlgorithm algorithm = null ) : byte[]
stream this
algorithm System.Security.Cryptography.HashAlgorithm
Результат byte[]

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

Determines if the directory contains the other directory or file at any depth.
public static Contains ( this dir, FileSystemInfo other ) : bool
dir this
other System.IO.FileSystemInfo
Результат bool

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

Determines if the directory directly contains the other directory or file.
public static ContainsDirectly ( this dir, FileSystemInfo other ) : bool
dir this
other System.IO.FileSystemInfo
Результат bool

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

public static ConvertToString ( this bytes ) : string
bytes this
Результат string

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

public static CreateFileSystemInfoFromPath ( this path ) : FileSystemInfo
path this
Результат System.IO.FileSystemInfo

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

public static EnsureExists ( this dir ) : DirectoryInfo
dir this
Результат System.IO.DirectoryInfo

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

public static EnumerateBytes ( this file ) : IEnumerable
file this
Результат IEnumerable

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

Yields each part of the path, ordered from the root to the item.
public static EnumeratePathDownFromRoot ( this source ) : IEnumerable
source this
Результат IEnumerable

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

Yields each part of the path, ordered from the item to the root.
public static EnumeratePathUpToRoot ( this source ) : IEnumerable
source this
Результат IEnumerable

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

public static GetFile ( this directory, string file ) : FileInfo
directory this
file string
Результат System.IO.FileInfo

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

public static GetParentDirectory ( this fileSystemInfo ) : DirectoryInfo
fileSystemInfo this
Результат System.IO.DirectoryInfo

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

public static GetPath ( this specialFolder, Environment option = Environment.SpecialFolderOption.None ) : string
specialFolder this
option Environment
Результат string

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

public static GetRelativePathFrom ( this to, FileSystemInfo from ) : string
to this
from System.IO.FileSystemInfo
Результат string

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

public static GetRelativePathTo ( this from, FileSystemInfo to ) : string
from this
to System.IO.FileSystemInfo
Результат string

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

public static GetSubDirectory ( this directory ) : DirectoryInfo
directory this
Результат System.IO.DirectoryInfo

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

Returns files that haven't changed over a period of time.
public static GetUnchangedFiles ( this source, System.TimeSpan interval, CancellationToken cancellationToken = default(CancellationToken) ) : System.IO.FileInfo[]
source this Files to check.
interval System.TimeSpan Time to wait between checking the files.
cancellationToken System.Threading.CancellationToken Token to cancel the wait between checks.
Результат System.IO.FileInfo[]

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

Determines if the file or directory is contained directly within the the other directory.
public static IsContainedDirectlyWithin ( this fileOrDirectory, DirectoryInfo otherDir ) : bool
fileOrDirectory this
otherDir System.IO.DirectoryInfo
Результат bool

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

Determines if the file or directory is contained within the the other directory at any depth.
public static IsContainedWithin ( this fileOrDirectory, DirectoryInfo otherDir ) : bool
fileOrDirectory this
otherDir System.IO.DirectoryInfo
Результат bool

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

public static IsDirectoryPath ( this path ) : bool
path this
Результат bool

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

public static IsFilePath ( this path ) : bool
path this
Результат bool

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

Checks and rechecks a directory and all sub-directories for files. Only returns files that haven't changed between checks.
public static PollForAllFiles ( this di, System.TimeSpan interval, CancellationToken cancellationToken = default(CancellationToken) ) : System.IO.FileInfo[]
di this The directory to check.
interval System.TimeSpan The time between checking for files.
cancellationToken System.Threading.CancellationToken Token to cancel the wait between checks.
Результат System.IO.FileInfo[]

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

Checks and rechecks a directory for files. Only returns files that haven't changed between checks.
public static PollForFiles ( this di, System.TimeSpan interval, string searchPattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly, CancellationToken cancellationToken = default(CancellationToken) ) : System.IO.FileInfo[]
di this The directory to check.
interval System.TimeSpan The time between checking for files.
searchPattern string The search pattern.
searchOption SearchOption The search options.
cancellationToken System.Threading.CancellationToken Token to cancel the wait between checks.
Результат System.IO.FileInfo[]

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

public static WhereCanOpen ( this files ) : IEnumerable
files this
Результат IEnumerable