Skip to content

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.

Constructors

Properties

  • 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.

Methods

  • 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.

Examples

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.

Clone this wiki locally