C# Class Serenity.IO.TemporaryFileHelper

Contains helper functions for temporary files and folders
Afficher le fichier Open project: volkanceylan/Serenity

Méthodes publiques

Свойство Type Description
DefaultAutoExpireTime System.TimeSpan

Méthodes publiques

Méthode Description
ClearTempFiles ( bool ignoreExpiry ) : void
Delete ( string filePath ) : void

Deletes a file.

Delete ( string filePath, DeleteType type ) : void

Deletes, tries to delete or marks a file for deletion depending on type.

PurgeDirectory ( string directoryToClean, System.TimeSpan autoExpireTime, int maxFilesInDirectory, string checkFileName ) : void

Clears a folder based on specified conditions

If any errors occur during cleanup, this doesn't raise an exception and ignored. Other errors might raise an exception. As errors are ignored, method can't gurantee that less than specified number of files will be in the folder after it ends.

PurgeDirectoryDefault ( string directoryToClean ) : void

Clears a folder based on default conditions

If any errors occur during cleanup, this doesn't raise an exception and ignored. Other errors might raise an exception. As errors are ignored, method can't gurantee that less than specified number of files will be in the folder after it ends.

RandomFileCode ( ) : string

Gets a 13 character random code that can be used safely in a filename

RegisterTempFile ( string filename, System.DateTime expiry, bool removeFolder ) : void
TryDelete ( string filePath ) : void

Tries to delete a file with given path.

TryDeleteMarkedFiles ( string path ) : void

Tries to delete all files that is marked for deletion by TryDeleteOrMark in a folder.

TryDeleteOrMark ( string filePath ) : void

Tries to delete a file or marks it for deletion by DeleteMarkedFiles method by creating a ".delete" file.

Method Details

ClearTempFiles() public static méthode

public static ClearTempFiles ( bool ignoreExpiry ) : void
ignoreExpiry bool
Résultat void

Delete() public static méthode

Deletes a file.
public static Delete ( string filePath ) : void
filePath string /// File to be deleted (can be null).
Résultat void

Delete() public static méthode

Deletes, tries to delete or marks a file for deletion depending on type.
public static Delete ( string filePath, DeleteType type ) : void
filePath string /// File to be deleted (can be null).
type DeleteType /// Delete type.
Résultat void

PurgeDirectory() public static méthode

Clears a folder based on specified conditions
If any errors occur during cleanup, this doesn't raise an exception and ignored. Other errors might raise an exception. As errors are ignored, method can't gurantee that less than specified number of files will be in the folder after it ends.
public static PurgeDirectory ( string directoryToClean, System.TimeSpan autoExpireTime, int maxFilesInDirectory, string checkFileName ) : void
directoryToClean string /// Folder to be cleared
autoExpireTime System.TimeSpan /// Files with creation time older than this is deleted. If passed as 0, time /// based cleanup is skipped.
maxFilesInDirectory int /// If more than this number of files exists, files will be deleted starting from /// oldest to newest. By passing 0, all files can be deleted. If passed as -1, /// file count based cleanup is skipped.
checkFileName string /// Safety file to be checked. If it is specified and it doesn't exists, operation /// is aborted.
Résultat void

PurgeDirectoryDefault() public static méthode

Clears a folder based on default conditions
If any errors occur during cleanup, this doesn't raise an exception and ignored. Other errors might raise an exception. As errors are ignored, method can't gurantee that less than specified number of files will be in the folder after it ends.
public static PurgeDirectoryDefault ( string directoryToClean ) : void
directoryToClean string /// Folder to be cleared
Résultat void

RandomFileCode() public static méthode

Gets a 13 character random code that can be used safely in a filename
public static RandomFileCode ( ) : string
Résultat string

RegisterTempFile() public static méthode

public static RegisterTempFile ( string filename, System.DateTime expiry, bool removeFolder ) : void
filename string
expiry System.DateTime
removeFolder bool
Résultat void

TryDelete() public static méthode

Tries to delete a file with given path.
public static TryDelete ( string filePath ) : void
filePath string /// File to be deleted (can be null).
Résultat void

TryDeleteMarkedFiles() public static méthode

Tries to delete all files that is marked for deletion by TryDeleteOrMark in a folder.
public static TryDeleteMarkedFiles ( string path ) : void
path string /// Path of marked files to be deleted
Résultat void

TryDeleteOrMark() public static méthode

Tries to delete a file or marks it for deletion by DeleteMarkedFiles method by creating a ".delete" file.
public static TryDeleteOrMark ( string filePath ) : void
filePath string /// File to be deleted
Résultat void

Property Details

DefaultAutoExpireTime public_oe static_oe property

By default, files older than 1 hour is cleared
public static TimeSpan,System DefaultAutoExpireTime
Résultat System.TimeSpan