C# Class Serenity.IO.TemporaryFileHelper

Contains helper functions for temporary files and folders
Exibir arquivo Open project: volkanceylan/Serenity

Public Properties

Property Type Description
DefaultAutoExpireTime System.TimeSpan

Public Methods

Method 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 method

public static ClearTempFiles ( bool ignoreExpiry ) : void
ignoreExpiry bool
return void

Delete() public static method

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

Delete() public static method

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.
return void

PurgeDirectory() public static method

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.
return void

PurgeDirectoryDefault() public static method

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
return void

RandomFileCode() public static method

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

RegisterTempFile() public static method

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

TryDelete() public static method

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

TryDeleteMarkedFiles() public static method

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
return void

TryDeleteOrMark() public static method

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
return void

Property Details

DefaultAutoExpireTime public_oe static_oe property

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