C# Класс CodeCake.TemporaryFile

Small helper to automatically delete a temporary file. It is mainly a secure wrapper around GetTempFileName that creates a uniquely named, zero-byte temporary file on disk and returns the full path of that file: the P:Path property exposes it. This file is flagged by default with FileAttributes.Temporary (short-lived): it will automatically be deleted by the Operating System during if it is still here on reboot. (Borrowed from CK.Core.)
Наследование: IDisposable
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
Detach ( ) : void

Detaches the temporary file: it will no more be automatically destroyed. When created short-lived (see FileAttributes.Temporary), this flag is not reset: the file will be destroyed by the Operating System on the bext reboot.

Dispose ( ) : void

Attempts to delete the temporary file.

TemporaryFile ( ) : System

Initializes a new short lived TemporaryFile.

TemporaryFile ( bool shortLived ) : System

Initializes a new TemporaryFile. When shortLived is true, the FileAttributes.Temporary is set on the file.

TemporaryFile ( bool shortLived, string extension ) : System

Initializes a new TemporaryFile with an extension. When shortLived is true, the FileAttributes.Temporary is set on the file. The file will have a name looking like : xxxx.tmp.extension

When extension is ".", the final path will end with a ".".

TemporaryFile ( string extension ) : System

Initializes a new short lived TemporaryFile with an extension - the file will have a name looking like : xxxx.tmp.extension

Приватные методы

Метод Описание
DeleteFile ( ) : bool

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

Detach() публичный Метод

Detaches the temporary file: it will no more be automatically destroyed. When created short-lived (see FileAttributes.Temporary), this flag is not reset: the file will be destroyed by the Operating System on the bext reboot.
public Detach ( ) : void
Результат void

Dispose() публичный Метод

Attempts to delete the temporary file.
public Dispose ( ) : void
Результат void

TemporaryFile() публичный Метод

Initializes a new short lived TemporaryFile.
public TemporaryFile ( ) : System
Результат System

TemporaryFile() публичный Метод

Initializes a new TemporaryFile. When shortLived is true, the FileAttributes.Temporary is set on the file.
public TemporaryFile ( bool shortLived ) : System
shortLived bool True to set the on the file.
Результат System

TemporaryFile() публичный Метод

Initializes a new TemporaryFile with an extension. When shortLived is true, the FileAttributes.Temporary is set on the file. The file will have a name looking like : xxxx.tmp.extension
When extension is ".", the final path will end with a ".".
public TemporaryFile ( bool shortLived, string extension ) : System
shortLived bool True to set the on the file.
extension string Optional extension of the file (example : '.png' and 'png' would both work).
Результат System

TemporaryFile() публичный Метод

Initializes a new short lived TemporaryFile with an extension - the file will have a name looking like : xxxx.tmp.extension
public TemporaryFile ( string extension ) : System
extension string The extension of the file (example : '.png' and 'png' would both work)
Результат System