C# Class Utilities.FileUtilities

Utility class providing a collection of static utility methods.
Mostra file Open project: agardiner/hfmcmd

Public Methods

Method Description
ConvertWildcardPatternToRE ( string pattern ) : Regex

Converts a pattern containing ? and * characters into a case- insensitive regular expression.

EnsureDirExists ( string path ) : void

Checks if the specified directory exists, throwing an exception if it doesn't.

EnsureFileExists ( string path ) : void

Checks if the specified path exists, throwing an exception if it doesn't.

EnsureFileWriteable ( string path ) : void

Checks if the specified path can be written to.

FindMatchingFiles ( string sourceDir, string namePattern, bool includeSubDirs ) : List

Given a starting directory and a filename pattern, returns a list paths of files that match the name pattern.

GetBytes ( string str ) : byte[]

Convert a string to a byte array, using ASCII encoding.

GetDirectoryName ( string path ) : string

Returns the name of the directory, given a path to a directory

GetMatchingFiles ( string pathPattern ) : List

Given a path containing wildcards, returns the file(s) that match pattern.

PathDifference ( string path1, string path2 ) : string

Returns the part of path2 that is not in path1.

Private Methods

Method Description
FindMatchingFiles ( string sourceDir, Regex nameRE, bool includeSubDirs, int depth ) : List

Method Details

ConvertWildcardPatternToRE() public static method

Converts a pattern containing ? and * characters into a case- insensitive regular expression.
public static ConvertWildcardPatternToRE ( string pattern ) : Regex
pattern string
return System.Text.RegularExpressions.Regex

EnsureDirExists() public static method

Checks if the specified directory exists, throwing an exception if it doesn't.
public static EnsureDirExists ( string path ) : void
path string
return void

EnsureFileExists() public static method

Checks if the specified path exists, throwing an exception if it doesn't.
public static EnsureFileExists ( string path ) : void
path string
return void

EnsureFileWriteable() public static method

Checks if the specified path can be written to.
public static EnsureFileWriteable ( string path ) : void
path string
return void

FindMatchingFiles() public static method

Given a starting directory and a filename pattern, returns a list paths of files that match the name pattern.
public static FindMatchingFiles ( string sourceDir, string namePattern, bool includeSubDirs ) : List
sourceDir string
namePattern string
includeSubDirs bool
return List

GetBytes() public static method

Convert a string to a byte array, using ASCII encoding.
public static GetBytes ( string str ) : byte[]
str string
return byte[]

GetDirectoryName() public static method

Returns the name of the directory, given a path to a directory
public static GetDirectoryName ( string path ) : string
path string
return string

GetMatchingFiles() public static method

Given a path containing wildcards, returns the file(s) that match pattern.
public static GetMatchingFiles ( string pathPattern ) : List
pathPattern string
return List

PathDifference() public static method

Returns the part of path2 that is not in path1.
public static PathDifference ( string path1, string path2 ) : string
path1 string
path2 string
return string