Created
March 29, 2020 12:43
-
-
Save gabriel-lopez/c073d04727e867b35a01a8abe6b07c53 to your computer and use it in GitHub Desktop.
Utility class used to get a temporary folder path.
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 sealed class TempFolder | |
| { | |
| public string Path { get; } | |
| public TempFolder() | |
| { | |
| string guid = Guid.NewGuid().ToString(); | |
| string tempPath = System.IO.Path.GetTempPath(); | |
| string path = System.IO.Path.Combine(tempPath, guid); | |
| // ensure that the directory doesn't already exists | |
| while (Directory.Exists(path)) | |
| { | |
| guid = Guid.NewGuid().ToString(); | |
| path = System.IO.Path.Combine(tempPath, guid); | |
| } | |
| Path = Directory.CreateDirectory(path).FullName; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment