Skip to content
DocsTry Aspire
DocsTry

ITempFileSystemService Methods

InterfaceMethods2 members
Service for managing temporary directories and files within Aspire.
CreateTempFile(string?)Section titled CreateTempFile(string?)abstractTempFile
Creates a new temporary file and returns it.
public interface ITempFileSystemService
{
public abstract TempFile CreateTempFile(
string? fileName = null)
{
// ...
}
}
fileNamestring?optionalOptional file name for the temporary file (e.g., "config.json", "script.sh"). If null, uses a random name.
TempFileA 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.

Creates and returns a temporary subdirectory.
public interface ITempFileSystemService
{
public abstract TempDirectory CreateTempSubdirectory(
string? prefix = null)
{
// ...
}
}
prefixstring?optionalOptional prefix for the subdirectory name (e.g., "aspire").
TempDirectoryA 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.