C# Class CoreTechs.Common.FileSystemExtensions

Afficher le fichier Open project: Core-Techs/Common

Méthodes publiques

Méthode Description
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

Method Details

AreSame() public static méthode

public static AreSame ( this a, DirectoryInfo b ) : bool
a this
b System.IO.DirectoryInfo
Résultat bool

AreSame() public static méthode

public static AreSame ( this a, FileInfo b ) : bool
a this
b System.IO.FileInfo
Résultat bool

AttemptOpen() public static méthode

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.
Résultat Attempt

ComputeFileHash() public static méthode

public static ComputeFileHash ( this fileInfo, HashAlgorithm algorithm = null ) : string
fileInfo this
algorithm System.Security.Cryptography.HashAlgorithm
Résultat string

ComputeHash() public static méthode

public static ComputeHash ( this stream, HashAlgorithm algorithm = null ) : byte[]
stream this
algorithm System.Security.Cryptography.HashAlgorithm
Résultat byte[]

Contains() public static méthode

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
Résultat bool

ContainsDirectly() public static méthode

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
Résultat bool

ConvertToString() public static méthode

public static ConvertToString ( this bytes ) : string
bytes this
Résultat string

CreateFileSystemInfoFromPath() public static méthode

public static CreateFileSystemInfoFromPath ( this path ) : FileSystemInfo
path this
Résultat System.IO.FileSystemInfo

EnsureExists() public static méthode

public static EnsureExists ( this dir ) : DirectoryInfo
dir this
Résultat System.IO.DirectoryInfo

EnumerateBytes() public static méthode

public static EnumerateBytes ( this file ) : IEnumerable
file this
Résultat IEnumerable

EnumeratePathDownFromRoot() public static méthode

Yields each part of the path, ordered from the root to the item.
public static EnumeratePathDownFromRoot ( this source ) : IEnumerable
source this
Résultat IEnumerable

EnumeratePathUpToRoot() public static méthode

Yields each part of the path, ordered from the item to the root.
public static EnumeratePathUpToRoot ( this source ) : IEnumerable
source this
Résultat IEnumerable

GetFile() public static méthode

public static GetFile ( this directory, string file ) : FileInfo
directory this
file string
Résultat System.IO.FileInfo

GetParentDirectory() public static méthode

public static GetParentDirectory ( this fileSystemInfo ) : DirectoryInfo
fileSystemInfo this
Résultat System.IO.DirectoryInfo

GetPath() public static méthode

public static GetPath ( this specialFolder, Environment option = Environment.SpecialFolderOption.None ) : string
specialFolder this
option Environment
Résultat string

GetRelativePathFrom() public static méthode

public static GetRelativePathFrom ( this to, FileSystemInfo from ) : string
to this
from System.IO.FileSystemInfo
Résultat string

GetRelativePathTo() public static méthode

public static GetRelativePathTo ( this from, FileSystemInfo to ) : string
from this
to System.IO.FileSystemInfo
Résultat string

GetSubDirectory() public static méthode

public static GetSubDirectory ( this directory ) : DirectoryInfo
directory this
Résultat System.IO.DirectoryInfo

GetUnchangedFiles() public static méthode

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.
Résultat System.IO.FileInfo[]

IsContainedDirectlyWithin() public static méthode

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
Résultat bool

IsContainedWithin() public static méthode

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
Résultat bool

IsDirectoryPath() public static méthode

public static IsDirectoryPath ( this path ) : bool
path this
Résultat bool

IsFilePath() public static méthode

public static IsFilePath ( this path ) : bool
path this
Résultat bool

PollForAllFiles() public static méthode

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.
Résultat System.IO.FileInfo[]

PollForFiles() public static méthode

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.
Résultat System.IO.FileInfo[]

WhereCanOpen() public static méthode

public static WhereCanOpen ( this files ) : IEnumerable
files this
Résultat IEnumerable