C# Class CK.Core.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.
Inheritance: IDisposable
Afficher le fichier Open project: Invenietis/ck-core

Méthodes publiques

Méthode Description
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

Private Methods

Méthode Description
DeleteFile ( ) : bool

Method Details

Detach() public méthode

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
Résultat void

Dispose() public méthode

Attempts to delete the temporary file.
public Dispose ( ) : void
Résultat void

TemporaryFile() public méthode

Initializes a new short lived TemporaryFile.
public TemporaryFile ( ) : System
Résultat System

TemporaryFile() public méthode

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.
Résultat System

TemporaryFile() public méthode

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).
Résultat System

TemporaryFile() public méthode

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)
Résultat System