Property | Type | Description | |
---|---|---|---|
AltDirectorySeparatorString | string | ||
DirectorySeparatorString | string | ||
FileNameUniqueTimeUtcFormat | string | ||
GzipFileHeader | byte[] | ||
InexistingFile | FileAttributes | ||
MissingFileLastWriteTimeUtc | System.DateTime |
Method | Description | |
---|---|---|
CheckForWriteAccess ( string path, int nbMaxMilliSecond ) : bool |
Waits for a file to be writable or does not exist (if it does not exist, it can be created!). The file is opened and close. Waits the number of nbMaxMilliSecond before leaving and returning false: when 0 (the default), there is no wai. A nbMaxMilliSecond below 20 ~ 30 milliseconds is not accurate: even with nbMaxMilliSecond = 1 this method will return true if the file becomes writable during the next 10 or 20 milliseconds.
|
|
CompressFileToGzipFile ( string sourceFilePath, string destinationPath, bool deleteSourceFileOnSuccess, CompressionLevel level = CompressionLevel.Optimal, int bufferSize = 64*1024 ) : void |
Compresses a file to another file, using GZip at the given compression level.
|
|
CompressFileToGzipFileAsync ( string sourceFilePath, string destinationPath, |
Compresses a file to another file asynchronously, using GZip at the given compression level.
|
|
CopyDirectory ( |
Recursively copy a directory, creates it if it does not already exists. Throws an IOException, if a same file exists in the target directory.
|
|
CreateAndOpenUniqueTimedFile ( string pathPrefix, string fileSuffix, System.DateTime time, FileAccess access, FileShare share, int bufferSize, FileOptions options, int maxTryBeforeGuid = 512 ) : |
Creates and opens a new necessarily unique file in a directory that must exist. The file name is based on a DateTime, with an eventual uniquifier if a file already exists with the same name. You can use FileStream.Name to obtain the file name.
|
|
EnsureUniqueTimedFile ( string pathPrefix, string fileSuffix, System.DateTime time, int maxTryBeforeGuid = 512 ) : string |
Gets a path to a necessarily unique named file. The file name is based on a DateTime, with an eventual uniquifier if a file already exists with the same name.
|
|
FormatTimedUniqueFilePart ( System.DateTime time ) : string |
Formats a string that is file name compatible from the given time and a Guid.NewGuid() where time uses FileNameUniqueTimeUtcFormat and the new Guid is encoded with http://en.wikipedia.org/wiki/Base64#URL_applications.
|
|
IndexOfInvalidFileNameChars ( string path ) : int |
Finds the first character index of any characters that are invalid in a file name. This method (and IndexOfInvalidPathChars) avoid the allocation of the array each time Path.GetInvalidFileNameChars is called.
|
|
IndexOfInvalidPathChars ( string path ) : int |
Finds the first character index of any characters that are invalid in a path. This method (and IndexOfInvalidFileNameChars) avoid the allocation of the array each time Path.GetInvalidPathChars is called.
|
|
MatchFileNameUniqueTimeUtcFormat ( this @this, System.DateTime &time ) : bool |
Matches a DateTime in the FileNameUniqueTimeUtcFormat format.
|
|
MoveToUniqueTimedFile ( string sourceFilePath, string pathPrefix, string fileSuffix, System.DateTime time, int maxTryBeforeGuid = 512 ) : string |
Moves (renames) a file to a necessarily unique named file. The file name is based on a DateTime, with an eventual uniquifier if a file already exists with the same name.
|
|
NormalizePathSeparator ( string path, bool ensureTrailingBackslash ) : string |
Canonicalizes the path: all '/' and '\' are mapped to Path.DirectorySeparatorChar (and Path.AltDirectorySeparatorChar will also be transformed).
|
|
TryParseFileNameUniqueTimeUtcFormat ( string s, System.DateTime &time, bool allowSuffix = false ) : bool |
Tries to parse a string formatted with the FileNameUniqueTimeUtcFormat. The string must contain only the time unless allowSuffix is true.
|
|
WriteUniqueTimedFile ( string pathPrefix, string fileSuffix, System.DateTime time, byte content, bool withUTF8Bom, int maxTryBeforeGuid = 3 ) : string |
Creates a new necessarily unique file and writes bytes content in a directory that must exist. The file name is based on a DateTime, with an eventual uniquifier if a file already exists with the same name.
|
Method | Description | |
---|---|---|
FindUniqueTimedFile ( string pathPrefix, string fileSuffix, System.DateTime time, int maxTryBeforeGuid, bool>.Func |
||
TryCreateFile ( string path ) : bool | ||
TryCreateNew ( string timedPath, FileAccess access, FileShare share, int bufferSize, FileOptions options, |
||
TryMoveTo ( string sourceFilePath, string timedPath ) : bool |
static public CheckForWriteAccess ( string path, int nbMaxMilliSecond ) : bool | ||
path | string | The path of the file to write to. |
nbMaxMilliSecond | int | Maximum number of milliseconds to wait before returning false. |
return | bool |
public static CompressFileToGzipFile ( string sourceFilePath, string destinationPath, bool deleteSourceFileOnSuccess, CompressionLevel level = CompressionLevel.Optimal, int bufferSize = 64*1024 ) : void | ||
sourceFilePath | string | The source file path. |
destinationPath | string | The destination path. If it doesn't exist, it will be created. If it exists, it will be replaced. |
deleteSourceFileOnSuccess | bool | if set to |
level | CompressionLevel | Compression level to use. |
bufferSize | int | Size of the buffer, in bytes. |
return | void |
public static CompressFileToGzipFileAsync ( string sourceFilePath, string destinationPath, |
||
sourceFilePath | string | The source file path. |
destinationPath | string | The destination path. If it doesn't exist, it will be created. If it exists, it will be replaced. |
cancellationToken | Optional cancellation token for the task. | |
deleteSourceFileOnSuccess | bool | If set to |
level | CompressionLevel | Compression level to use. |
bufferSize | int | Size of the buffer, in bytes. |
return | Task |
public static CopyDirectory ( |
||
src | The source directory. | |
target | The target directory. | |
withHiddenFiles | bool | False to skip hidden files. |
withHiddenFolders | bool | False to skip hidden folders. |
fileFilter | bool>.Func | Optional predicate for directories. |
dirFilter | bool>.Func | Optional predicate for files. |
return | void |
public static CreateAndOpenUniqueTimedFile ( string pathPrefix, string fileSuffix, System.DateTime time, FileAccess access, FileShare share, int bufferSize, FileOptions options, int maxTryBeforeGuid = 512 ) : |
||
pathPrefix | string | The path prefix. Must not be null. Must be a valid path and may ends with a prefix for the file name itself. |
fileSuffix | string | Suffix for the file name. Must not be null. Typically an extension (like ".txt"). |
time | System.DateTime | The time that will be used to create the file name. It must be an UTC time. |
access | FileAccess |
/// A constant that determines how the file can be accessed by the FileStream object.
/// It can only be |
share | FileShare | /// A constant that determines how the file will be shared by processes. /// |
bufferSize | int | /// A positive Int32 value greater than 0 indicating the buffer size. For bufferSize values between one and eight, the actual buffer size is set to eight bytes. /// |
options | FileOptions | Specifies additional file options. |
maxTryBeforeGuid | int | /// Maximum value for short hexadecimal uniquifier before using a base 64 guid suffix. Must greater than 0. |
return |
public static EnsureUniqueTimedFile ( string pathPrefix, string fileSuffix, System.DateTime time, int maxTryBeforeGuid = 512 ) : string | ||
pathPrefix | string | The path prefix. Must not be null. Must be a valid path and may ends with a prefix for the file name itself. |
fileSuffix | string | Suffix for the file name. Must not be null. Typically an extension (like ".txt"). |
time | System.DateTime | The time that will be used to create the file name. It must be an UTC time. |
maxTryBeforeGuid | int | /// Maximum value for short hexadecimal uniquifier before using a base 64 guid suffix. Must greater than 0. /// |
return | string |
public static FormatTimedUniqueFilePart ( System.DateTime time ) : string | ||
time | System.DateTime | The date time to use. |
return | string |
public static IndexOfInvalidFileNameChars ( string path ) : int | ||
path | string | Path to check. Can not be null. |
return | int |
public static IndexOfInvalidPathChars ( string path ) : int | ||
path | string | Path to check. Can not be null. |
return | int |
public static MatchFileNameUniqueTimeUtcFormat ( this @this, System.DateTime &time ) : bool | ||
@this | this | |
time | System.DateTime | Result time on success; otherwise |
return | bool |
public static MoveToUniqueTimedFile ( string sourceFilePath, string pathPrefix, string fileSuffix, System.DateTime time, int maxTryBeforeGuid = 512 ) : string | ||
sourceFilePath | string | Path of the file to move. |
pathPrefix | string | The path prefix. Must not be null. Must be a valid path and may ends with a prefix for the file name itself. |
fileSuffix | string | Suffix for the file name. Must not be null. Typically an extension (like ".txt"). |
time | System.DateTime | The time that will be used to create the file name. It must be an UTC time. |
maxTryBeforeGuid | int | /// Maximum value for short hexadecimal uniquifier before using a base 64 guid suffix. Must greater than 0. /// |
return | string |
static public NormalizePathSeparator ( string path, bool ensureTrailingBackslash ) : string | ||
path | string | The path to standardize (must be not be null). It is trimmed and if the path is empty, the empty string is returned. |
ensureTrailingBackslash | bool |
/// Ensures that the normalized path will end with a |
return | string |
public static TryParseFileNameUniqueTimeUtcFormat ( string s, System.DateTime &time, bool allowSuffix = false ) : bool | ||
s | string | The string to parse. |
time | System.DateTime | Result time on success. |
allowSuffix | bool | True to accept a string that starts with the time and contains more text. |
return | bool |
public static WriteUniqueTimedFile ( string pathPrefix, string fileSuffix, System.DateTime time, byte content, bool withUTF8Bom, int maxTryBeforeGuid = 3 ) : string | ||
pathPrefix | string | The path prefix. Must not be null. Must be a valid path and may ends with a prefix for the file name itself. |
fileSuffix | string | Suffix for the file name. Must not be null. Typically an extension (like ".txt"). |
time | System.DateTime | The time that will be used to create the file name. It should be an UTC time. |
content | byte | The bytes to write. Can be null or empty if the file must only be created. |
withUTF8Bom | bool | True to write the UTF8 Byte Order Mask (the preamble). |
maxTryBeforeGuid | int | Maximum value for short hexa uniquifier before using a base 64 guid suffix. Must between 0 and 15 (included). |
return | string |
public static string AltDirectorySeparatorString | ||
return | string |
public static string DirectorySeparatorString | ||
return | string |
public static string FileNameUniqueTimeUtcFormat | ||
return | string |
static public FileAttributes InexistingFile | ||
return | FileAttributes |