mirror of https://github.com/dahall/Vanara.git
Added ability to get a filename only by passing 'null' to constructor. Fixed disposal so can't error.
parent
b7cedf436f
commit
6e70fc0b19
|
@ -15,7 +15,11 @@ namespace Vanara.PInvoke.Tests
|
|||
|
||||
public TempFile(string contents = tmpstr)
|
||||
{
|
||||
FullName = Path.GetTempFileName(); File.WriteAllText(FullName, contents);
|
||||
FullName = Path.GetTempFileName();
|
||||
if (contents is null)
|
||||
File.Delete(FullName);
|
||||
else
|
||||
File.WriteAllText(FullName, contents);
|
||||
}
|
||||
|
||||
public string FullName { get; }
|
||||
|
@ -23,7 +27,9 @@ namespace Vanara.PInvoke.Tests
|
|||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
hFile?.Dispose(); File.Delete(FullName);
|
||||
hFile?.Dispose();
|
||||
if (File.Exists(FullName))
|
||||
File.Delete(FullName);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue