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