Class FileUtility
File Utilities methods.
public class FileUtility
- Inheritance
-
FileUtility
Methods
EnumerateDirectories(string, SearchDirection)
public static IEnumerable<DirectoryInfo> EnumerateDirectories(string rootDirectory, SearchDirection direction)
Parameters
rootDirectory
stringdirection
SearchDirection
Returns
GetAbsolutePath(string)
Converts a relative path to an absolute path using the current working directoy.
public static string GetAbsolutePath(string filePath)
Parameters
filePath
stringThe file path.
Returns
- string
An absolute path.
GetFileExtensions(string)
Gets the file extensions normalized separated by ',' ';'.
public static string[] GetFileExtensions(string fileExtensions)
Parameters
fileExtensions
stringThe file extensions separated by ',' ';'.
Returns
- string[]
An array of file extensions.
GetFileExtensionsAsSet(string)
Gets the file extensions normalized separated by ',' ';'.
public static HashSet<string> GetFileExtensionsAsSet(string fileExtensions)
Parameters
fileExtensions
stringThe file extensions separated by ',' ';'.
Returns
IsFileLocked(FileInfo)
Determines whether the specified file is locked.
public static bool IsFileLocked(FileInfo file)
Parameters
file
FileInfoThe file.
Returns
- bool
true
if the specified file is locked; otherwise,false
.
Exceptions
- ArgumentNullException
file
is null
IsFileLocked(string)
Determines whether the specified file is locked.
public static bool IsFileLocked(string filePath)
Parameters
filePath
stringThe file path.
Returns
- bool
true
if the specified file is locked; otherwise,false
.
Exceptions
- ArgumentNullException
filePath
is null
NormalizeFileExtension(string)
Normalizes the file extension by adding a '.' prefix and making it lowercase.
public static string NormalizeFileExtension(string fileExtension)
Parameters
fileExtension
stringThe file extension.
Returns
- string
A normalized file extension.