-
Notifications
You must be signed in to change notification settings - Fork 2
BizArk.Core.Util.TempFile
Brian Brewder edited this page Apr 4, 2017
·
2 revisions
Back to BizArk.Core API Reference
Manages a temporary file. Deletes the file when disposed.
public TempFile()public TempFile(string ext)-
public TempFile(string dir, string template)- See FileEx.GetUniqueFileName(string dir, string template) for description of parameters.
-
public bool Disposed { get; }- Gets a flag that determines if the temp file has been disposed. -
public string TempPath { get; }- Gets the path to the temporary file.
-
public void Append(string contents)- Appends the contents to the temp file. Creates the temp file if it doesn't already exist. -
public void Delete()- Deletes the temp file if it exists. -
public void Write(string contents)- Creates the temp file and writes the contents to it. -
public void Write(byte[] contents)- Creates the temp file and writes the contents to it.
using (var tmp = new TempFile())
{
// File does not exist yet.
tmp.Write("Hello World!");
// File created: "C:\Users\CptAwesome\AppData\Local\Temp\SuperAwesome.exe\33e8d2dd-2735-4709-a711-57cda5ad7b6f.tmp"
// File contents: "Hello World!"
}
// File deleted.