FFMpegCore/FFMpegCore.Test/TemporaryFile.cs

22 lines
533 B
C#
Raw Normal View History

namespace FFMpegCore.Test
2020-12-07 00:47:47 +01:00
{
public class TemporaryFile : IDisposable
{
private readonly string _path;
public TemporaryFile(string filename)
{
_path = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}-{filename}");
}
public static implicit operator string(TemporaryFile temporaryFile) => temporaryFile._path;
public void Dispose()
{
if (File.Exists(_path))
{
2020-12-07 00:47:47 +01:00
File.Delete(_path);
}
2020-12-07 00:47:47 +01:00
}
}
}