Method | Description | |
---|---|---|
AddPathSuffix ( string filePath ) : string |
Makes sure path is suffixed with standard Path.DirectorySeparatorChar.
|
|
ConnectToNetworkShare ( string sharename, string userName, string password, string domain ) : void |
Connects to a network share with the specified user's credentials.
|
|
DisconnectFromNetworkShare ( string sharename ) : void |
Disconnects the specified network share.
|
|
DisconnectFromNetworkShare ( string sharename, bool force ) : void |
Disconnects the specified network share.
|
|
DropPathRoot ( string filePath ) : string |
Remove any path root present in the path.
|
|
GetAbsolutePath ( string filePath ) : string |
Gets the absolute file path for the specified file name or relative file path.
|
|
GetApplicationDataFolder ( ) : string |
Gets the path to the folder where data related to the current application can be stored.
|
|
GetAvailableFreeSpace ( string pathName, long &freeSpace, long &totalSize ) : bool |
Tries to get the free space values for a given path. This path can be a network share or a mount point.
|
|
GetCommonApplicationDataFolder ( ) : string |
Gets the path to the folder where data related to the current application can be stored as well as shared among different users.
|
|
GetDirectoryName ( string filePath ) : string |
Gets the directory information from the specified file path. This differs from Path.GetDirectoryName in that it will see if last name in path is a directory and, if it exists, will properly treat that part of path as a directory. The .NET path function always assumes last entry is a file name if path is not suffixed with a slash. For example: Path.GetDirectoryName(@"C:\Music") will return "C:\", however, FilePath.GetDirectoryName(@"C:\Music") will return "C:\Music\", so long as Music directory exists. |
|
GetExtension ( string filePath ) : string |
Gets the extension from the specified file path.
|
|
GetFileLength ( string fileName ) : long |
Gets the size of the specified file.
|
|
GetFileList ( string path ) : string[] |
Gets a list of files under the specified path. Search wildcard pattern (c:\Data\*.dat) can be used for including only the files matching the pattern or path wildcard pattern (c:\Data\*\*.dat) to indicate the inclusion of files under all subdirectories in the list.
|
|
GetFileName ( string filePath ) : string |
Gets the file name and extension from the specified file path.
|
|
GetFileNameWithoutExtension ( string filePath ) : string |
Gets the file name without extension from the specified file path.
|
|
GetFilePatternRegularExpression ( string fileSpec ) : string |
Gets a regular expression pattern that simulates wildcard matching for filenames (wildcards are defined as '*' or '?' characters).
|
|
GetLastDirectoryName ( string filePath ) : string |
Gets the last directory name from a file path. GetLastDirectoryName(string) would return sub2 from c:\windows\sub2\filename.ext. |
|
GetUniqueFilePath ( string originalFilePath ) : string |
Gets a unique file path for the given file by checking for name collisions and adding a sequence number to the end of the file name if there is a collision. This method is designed to handle the case where the user wishes to create a file in a folder with a given name when there is a possibility that the name is already taken. Using this method, it is possible to create files with names in the following format:
|
|
GetUniqueFilePathWithBinarySearch ( string originalFilePath ) : string |
Gets a unique file path for the given file by checking for name collisions and adding a sequence number to the end of the file name if there is a collision. This method is designed to handle the case where the user wishes to create a file in a folder with a given name when there is a possibility that the name is already taken. Using this method, it is possible to create files with names in the following format:
|
|
GetValidFileName ( string fileName, char replaceWithCharacter = '_' ) : string |
Gets a valid file name by replacing invalid file name characters with replaceWithCharacter. This function expects a file name, not a file name with a path. To properly get a valid file path, where all directory names and the file name are validated, use the GetValidFilePath. Calling the GetValidFileName function will a full path will yield all directory separators replaced with the replaceWithCharacter. |
|
GetValidFilePath ( string filePath, char replaceWithCharacter = '_' ) : string |
Gets a valid file path by replacing invalid file or directory name characters with replaceWithCharacter.
|
|
InApplicationPath ( string filePath ) : bool |
Determines if the specified filePath is contained with the current executable path.
|
|
IsFilePatternMatch ( string fileSpecs, string filePath, bool ignoreCase ) : bool |
Determines whether the specified file name matches any of the given file specs (wildcards are defined as '*' or '?' characters). The syntax for fileSpecs adheres to the following rules:
|
|
IsValidFileName ( string filePath ) : bool |
Determines if the specified file name and path is valid.
|
|
RemovePathSuffix ( string filePath ) : string |
Makes sure path is not suffixed with Path.DirectorySeparatorChar or Path.AltDirectorySeparatorChar.
|
|
TrimFileName ( string filePath, int length ) : string |
Returns a file name, for display purposes, of the specified length using "..." to indicate a longer name. Minimum value for the length parameter is 12. 12 will be used for any value specified as less than 12. |
|
TryGetReadLock ( string fileName ) : bool |
Attempts to get read access on a file.
|
|
TryGetReadLockExclusive ( string fileName ) : bool |
Attempts to get read access on a file.
|
|
TryGetWriteLock ( string fileName ) : bool |
Attempts to get write access on a file.
|
|
ValidatePathName ( string filePath ) : void |
Ensures the supplied path name is valid. Throws argument exceptions if the |
|
WaitForReadLock ( string fileName ) : void |
Waits for the default duration (5 seconds) for read access on a file.
|
|
WaitForReadLock ( string fileName, double secondsToWait ) : void |
Waits for read access on a file for the specified number of seconds.
|
|
WaitForReadLockExclusive ( string fileName ) : void |
Waits for the default duration (5 seconds) for read access on a file.
|
|
WaitForReadLockExclusive ( string fileName, double secondsToWait ) : void |
Waits for read access on a file for the specified number of seconds.
|
|
WaitForWriteLock ( string fileName ) : void |
Waits for the default duration (5 seconds) for write access on a file.
|
|
WaitForWriteLock ( string fileName, double secondsToWait ) : void |
Waits for write access on a file for the specified number of seconds.
|
|
WaitTillExists ( string fileName ) : void |
Waits for the default duration (5 seconds) for a file to exist.
|
|
WaitTillExists ( string fileName, double secondsToWait ) : void |
Waits for a file to exist for the specified number of seconds.
|
Method | Description | |
---|---|---|
FilePath ( ) : System | ||
GetDiskFreeSpaceEx ( string lpDirectoryName, ulong &lpFreeBytesAvailable, ulong &lpTotalNumberOfBytes, ulong &lpTotalNumberOfFreeBytes ) : bool | ||
WNetAddConnection2 ( NETRESOURCE &lpNetResource, string lpPassword, string lpUsername, int dwFlags ) : int | ||
WNetCancelConnection2 ( string lpName, int dwFlags, [ fForce ) : int |
public static AddPathSuffix ( string filePath ) : string | ||
filePath | string | The file path to be suffixed. |
return | string |
public static ConnectToNetworkShare ( string sharename, string userName, string password, string domain ) : void | ||
sharename | string | UNC share name to connect to. |
userName | string | User name to use for connection. |
password | string | Password to use for connection. |
domain | string | Domain name to use for connection. Specify the computer name for local system accounts. |
return | void |
public static DisconnectFromNetworkShare ( string sharename ) : void | ||
sharename | string | UNC share name to disconnect from. |
return | void |
public static DisconnectFromNetworkShare ( string sharename, bool force ) : void | ||
sharename | string | UNC share name to disconnect from. |
force | bool | |
return | void |
public static DropPathRoot ( string filePath ) : string | ||
filePath | string | The file path whose root is to be removed. |
return | string |
public static GetAbsolutePath ( string filePath ) : string | ||
filePath | string | File name or relative file path. |
return | string |
public static GetApplicationDataFolder ( ) : string | ||
return | string |
public static GetAvailableFreeSpace ( string pathName, long &freeSpace, long &totalSize ) : bool | ||
pathName | string | The path to the location |
freeSpace | long | The number of user space bytes |
totalSize | long | The total number of bytes on the drive. |
return | bool |
public static GetCommonApplicationDataFolder ( ) : string | ||
return | string |
public static GetDirectoryName ( string filePath ) : string | ||
filePath | string | The file path from which the directory information is to be obtained. |
return | string |
public static GetExtension ( string filePath ) : string | ||
filePath | string | The file path from which the extension is to be obtained. |
return | string |
public static GetFileLength ( string fileName ) : long | ||
fileName | string | Name of file whose size is to be retrieved. |
return | long |
public static GetFileList ( string path ) : string[] | ||
path | string | The path for which a list of files is to be returned. |
return | string[] |
public static GetFileName ( string filePath ) : string | ||
filePath | string | The file path from which the file name and extension is to be obtained. |
return | string |
public static GetFileNameWithoutExtension ( string filePath ) : string | ||
filePath | string | The file path from which the file name is to be obtained. |
return | string |
public static GetFilePatternRegularExpression ( string fileSpec ) : string | ||
fileSpec | string | The file spec for which the regular expression pattern if to be generated. |
return | string |
public static GetLastDirectoryName ( string filePath ) : string | ||
filePath | string | The file path from where the last directory name is to be retrieved. |
return | string |
public static GetUniqueFilePath ( string originalFilePath ) : string | ||
originalFilePath | string | The path to the original file before adding the sequence number. |
return | string |
public static GetUniqueFilePathWithBinarySearch ( string originalFilePath ) : string | ||
originalFilePath | string | The path to the original file before adding the sequence number. |
return | string |
public static GetValidFileName ( string fileName, char replaceWithCharacter = '_' ) : string | ||
fileName | string | File name to validate. |
replaceWithCharacter | char | Character to replace invalid file name characters with. Set to '\0' to remove invalid file name characters. |
return | string |
public static GetValidFilePath ( string filePath, char replaceWithCharacter = '_' ) : string | ||
filePath | string | File path to validate. |
replaceWithCharacter | char | Character to replace invalid file or directory name characters with. Set to '\0' to remove invalid file or directory name characters. |
return | string |
public static InApplicationPath ( string filePath ) : bool | ||
filePath | string | File name or relative file path. |
return | bool |
public static IsFilePatternMatch ( string fileSpecs, string filePath, bool ignoreCase ) : bool | ||
fileSpecs | string | The file specs used for matching the specified file name. |
filePath | string | The file path to be tested against the specified file specs for a match. |
ignoreCase | bool | |
return | bool |
public static IsValidFileName ( string filePath ) : bool | ||
filePath | string | The file name with optional path to test for validity. |
return | bool |
public static RemovePathSuffix ( string filePath ) : string | ||
filePath | string | The file path to be unsuffixed. |
return | string |
public static TrimFileName ( string filePath, int length ) : string | ||
filePath | string | The file path to be trimmed. |
length | int | The maximum length of the trimmed file path. |
return | string |
public static TryGetReadLock ( string fileName ) : bool | ||
fileName | string | The file to check for read access. |
return | bool |
public static TryGetReadLockExclusive ( string fileName ) : bool | ||
fileName | string | The file to check for read access. |
return | bool |
public static TryGetWriteLock ( string fileName ) : bool | ||
fileName | string | The file to check for write access. |
return | bool |
public static ValidatePathName ( string filePath ) : void | ||
filePath | string | The file path to be validated. |
return | void |
public static WaitForReadLock ( string fileName ) : void | ||
fileName | string | The name of the file to wait for to obtain read access. |
return | void |
public static WaitForReadLock ( string fileName, double secondsToWait ) : void | ||
fileName | string | The name of the file to wait for to obtain read access. |
secondsToWait | double | The time to wait for in seconds to obtain read access on a file. Set to zero to wait infinitely. |
return | void |
public static WaitForReadLockExclusive ( string fileName ) : void | ||
fileName | string | The name of the file to wait for to obtain read access. |
return | void |
public static WaitForReadLockExclusive ( string fileName, double secondsToWait ) : void | ||
fileName | string | The name of the file to wait for to obtain read access. |
secondsToWait | double | The time to wait for in seconds to obtain read access on a file. Set to zero to wait infinitely. |
return | void |
public static WaitForWriteLock ( string fileName ) : void | ||
fileName | string | The name of the file to wait for to obtain write access. |
return | void |
public static WaitForWriteLock ( string fileName, double secondsToWait ) : void | ||
fileName | string | The name of the file to wait for to obtain write access. |
secondsToWait | double | The time to wait for in seconds to obtain write access on a file. Set to zero to wait infinitely. |
return | void |
public static WaitTillExists ( string fileName ) : void | ||
fileName | string | The name of the file to wait for until it is created. |
return | void |
public static WaitTillExists ( string fileName, double secondsToWait ) : void | ||
fileName | string | The name of the file to wait for until it is created. |
secondsToWait | double | The time to wait for in seconds for the file to be created. Set to zero to wait infinitely. |
return | void |