When you needs of delete the directory of an EXE Application on .NET, it isn't possible when the app is running on the memory. Is very common when you've developing an Uninstaller project that clean himself for an complete uninstall. We have this solution for it: ---001: Create a temp directory of your application and copy your main EXE into it replacing before InitializeComponent method: Code: if (!Application.ExecutablePath.ToUpper().Contains(Path.GetTempPath().ToUpper())) { string tmpPthName = Path.GetTempPath() + "\\" + Path.GetRandomFileName(); string tmpFilName = tmpPthName + "\\" + Path.GetFileName(Application.ExecutablePath); try { Directory.CreateDirectory(tmpPthName); File.Copy(Application.ExecutablePath, tmpFilName); Process.Start(tmpFilName); Application.ExitThread(); Environment.Exit(0); } catch { } } else Directory.SetCurrentDirectory(Path.GetTempPath()); ---002: Add to FormClosed event this arguments to self-delete the temp EXE when it's running on temp directory: Code: if (Application.ExecutablePath.ToUpper().Contains(Path.GetTempPath().ToUpper())) { int PID = Process.GetCurrentProcess().Id; string cAppPath = @"""" + Path.GetDirectoryName(Application.ExecutablePath) + @""""; Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.Arguments = "/C TASKKILL /F /PID " + PID + @" & RD /S /Q " + cAppPath; p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; p.Start(); } And done The project always will run in a temp directory leaving the open instance of the main EXE on your hard disk and auto-cleaning on the temp folder after exit. Now you can delete the directory or the main EXE of the application without any problem in any time with the code.