Created
July 25, 2021 15:49
-
-
Save brianmed/378a3ed1928048105bd5746abdd157c8 to your computer and use it in GitHub Desktop.
CreateTempFileWithExtension C# .Net
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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