Skip to content
Docs Try Aspire

ITempFileSystemService Methods

Interface Methods 2 members
Service for managing temporary directories and files within Aspire.
CreateTempFile(string?) Section titled CreateTempFile(string?) abstract TempFile
Creates a new temporary file and returns it.
public interface ITempFileSystemService
{
public abstract TempFile CreateTempFile(
string? fileName = null)
{
// ...
}
}
fileName string? optional Optional file name for the temporary file (e.g., "config.json", "script.sh"). If null, uses a random name.
TempFile A TempFile representing the created temporary file. Dispose to delete.

This method creates a new temporary file. If a file name is specified, it creates a temporary subdirectory and places the file with that name inside it. If no file name is specified, it uses Path.GetTempFileName. Dispose the returned object to delete the file.

Use this instead of calling Path.GetTempFileName directly.

CreateTempSubdirectory(string?) Section titled CreateTempSubdirectory(string?) abstract TempDirectory
Creates and returns a temporary subdirectory.
public interface ITempFileSystemService
{
public abstract TempDirectory CreateTempSubdirectory(
string? prefix = null)
{
// ...
}
}
prefix string? optional Optional prefix for the subdirectory name (e.g., "aspire").
TempDirectory A TempDirectory representing the created temporary subdirectory. Dispose to delete.

This method creates a unique temporary subdirectory using the system temp folder. The directory is created immediately. Dispose the returned object to delete the directory.

Use this instead of calling Directory.CreateTempSubdirectory directly.