C# Класс Serenity.IO.TemporaryFileHelper

Contains helper functions for temporary files and folders
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
DefaultAutoExpireTime System.TimeSpan

Открытые методы

Метод Описание
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.

Описание методов

ClearTempFiles() публичный статический Метод

public static ClearTempFiles ( bool ignoreExpiry ) : void
ignoreExpiry bool
Результат void

Delete() публичный статический Метод

Deletes a file.
public static Delete ( string filePath ) : void
filePath string /// File to be deleted (can be null).
Результат void

Delete() публичный статический Метод

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.
Результат void

PurgeDirectory() публичный статический Метод

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.
Результат void

PurgeDirectoryDefault() публичный статический Метод

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
Результат void

RandomFileCode() публичный статический Метод

Gets a 13 character random code that can be used safely in a filename
public static RandomFileCode ( ) : string
Результат string

RegisterTempFile() публичный статический Метод

public static RegisterTempFile ( string filename, System.DateTime expiry, bool removeFolder ) : void
filename string
expiry System.DateTime
removeFolder bool
Результат void

TryDelete() публичный статический Метод

Tries to delete a file with given path.
public static TryDelete ( string filePath ) : void
filePath string /// File to be deleted (can be null).
Результат void

TryDeleteMarkedFiles() публичный статический Метод

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
Результат void

TryDeleteOrMark() публичный статический Метод

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
Результат void

Описание свойств

DefaultAutoExpireTime публичное статическое свойство

By default, files older than 1 hour is cleared
public static TimeSpan,System DefaultAutoExpireTime
Результат System.TimeSpan