Class TemporaryFile
Represents a temporary file that is automatically deleted when the object is disposed.
[MustDisposeResource]
public class TemporaryFile
- Inheritance
-
objectTemporaryFile
- Extension Methods
Constructors
TemporaryFile(string, string?)
Creates a uniquely named, empty temporary file on disk.
public TemporaryFile(string prefix, string? parentDirectory = null)
Parameters
prefixstringA short string the directory name should start with.
parentDirectorystringThe path of the directory the file should be created in. Leave
nullto use the default temp directory.
Exceptions
- IOException
A problem occurred while creating the temporary file.
- UnauthorizedAccessException
Creating a file in System.IO.Path.GetTempPath() is not permitted.
Properties
Path
The fully qualified path of the temporary file.
public string Path { get; }
Property Value
- string
Methods
Dispose()
Deletes the temporary file.
public virtual void Dispose()
ToString()
Returns Path.
public override string ToString()
Returns
- string
Operators
implicit operator string(TemporaryFile)
public static implicit operator string(TemporaryFile file)
Parameters
fileTemporaryFile
Returns
- string