TemporaryDirectory will deleted at the end of process, Path of NSIS is besite of base directory.

This commit is contained in:
2018-08-02 10:23:45 +02:00
parent f8ca13d7e6
commit d85858b0c1
6 changed files with 70 additions and 50 deletions

View 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.
}
}
}
}

View File

@ -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)