forked from sbozzie/test-intel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTempDirectory.cs
More file actions
42 lines (36 loc) · 1.18 KB
/
Copy pathTempDirectory.cs
File metadata and controls
42 lines (36 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Globalization;
using System.IO;
namespace PleaseIgnore.IntelMap.Tests {
/// <summary>
/// Creates a new directory that is automatically removed when this
/// class is disposed.
/// </summary>
internal sealed class TempDirectory : IDisposable {
private readonly string directoryName;
public TempDirectory() {
this.directoryName = Path.Combine(
System.IO.Path.GetTempPath(),
"tmp-" + DateTime.UtcNow.ToString(
"yyyyMMdd-HHmmss",
CultureInfo.InvariantCulture
));
Directory.CreateDirectory(this.directoryName);
}
public DirectoryInfo DirectoryInfo {
get { return new DirectoryInfo(this.directoryName); }
}
public string FullName {
get { return this.directoryName; }
}
public string Name {
get { return Path.GetFileName(directoryName); }
}
public void Dispose() {
try {
Directory.Delete(this.directoryName, true);
} catch (IOException) {
}
}
}
}