Commit 168386f5 authored by Leander Schulten's avatar Leander Schulten
Browse files

"unset" the current dir to not have an open handle to the folder of the...

"unset" the current dir to not have an open handle to the folder of the Lichtsteuerung that we want to replace
parent 85f39584
Pipeline #144185 passed with stage
in 1 minute and 15 seconds
......@@ -64,6 +64,28 @@ namespace WindowsInstaller
return false;
}
// https://stackoverflow.com/questions/329355/cannot-delete-directory-with-directory-deletepath-true
public static void DeleteDirectory(string path)
{
foreach (string directory in Directory.GetDirectories(path))
{
DeleteDirectory(directory);
}
try
{
Directory.Delete(path, true);
}
catch (IOException)
{
Directory.Delete(path, true);
}
catch (UnauthorizedAccessException)
{
Directory.Delete(path, true);
}
}
private void Form1_Shown(object sender, EventArgs e)
{
var thread = new Thread(() =>
......@@ -82,7 +104,7 @@ namespace WindowsInstaller
{
try
{
Directory.Delete(to, true);
DeleteDirectory(to);
}
catch (Exception ex)
{
......
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsInstaller
{
......@@ -14,7 +15,9 @@ namespace WindowsInstaller
[STAThread]
static void Main(string[] args)
{
if(args.Length != 2)
// we have an open handle to the current dir. If the current dir in the release folder we can not delete this
Environment.CurrentDirectory = "C:\\";
if (args.Length != 2)
{
MessageBox.Show("Programm mit den falschen Parametern gestartet, diese sind 'from' 'to'", "Fehler");
return;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment