TemporaryDirectory will deleted at the end of process, Path of NSIS is besite of base directory.
This commit is contained in:
28
Creator/Helper/TemporaryDirectory.cs
Normal file
28
Creator/Helper/TemporaryDirectory.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace KattekerCreator.Helper
|
||||
{
|
||||
public class TemporaryDirectory : IDisposable
|
||||
{
|
||||
public string Path { get; }
|
||||
|
||||
public TemporaryDirectory(string path)
|
||||
{
|
||||
Path = path;
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
System.IO.Directory.Delete(Path, true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
//ignore.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ namespace KattekerCreator.Helper
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string CreateTempDirectory()
|
||||
public static TemporaryDirectory CreateTempDirectory()
|
||||
{
|
||||
string result;
|
||||
do
|
||||
@ -29,7 +29,7 @@ namespace KattekerCreator.Helper
|
||||
} while (Directory.Exists(result));
|
||||
|
||||
Directory.CreateDirectory(result);
|
||||
return result;
|
||||
return new TemporaryDirectory(result);
|
||||
}
|
||||
|
||||
public static bool IsFilesizeWrong(string filename)
|
||||
|
Reference in New Issue
Block a user