Skip to content

Instantly share code, notes, and snippets.

@brianmed
Created July 25, 2021 15:49
Show Gist options
  • Save brianmed/378a3ed1928048105bd5746abdd157c8 to your computer and use it in GitHub Desktop.
Save brianmed/378a3ed1928048105bd5746abdd157c8 to your computer and use it in GitHub Desktop.
CreateTempFileWithExtension C# .Net
public string CreateTempFileWithExtension(string extension)
{
string file = string.Empty;
do
{
file = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid().ToString()}.{extension}");
} while (File.Exists(file));
return file;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment