I am trying to get the location of an Executable running in memory using Application.ExecutablePath and delete it from its current location, however i get the error The system cannot find the file specified.
As far as my understanding goes it is because of the space in the path. How do i fix this problem? Here is the relevant code:
System.Diagnostics.Process p = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
psi.FileName = @"cmd.exe /C Del " + Path.GetFullPath(Application.ExecutablePath);
p.StartInfo = psi;
p.Start();
I tend to prefer
String.Formatover simple string concats:Otherwise, I believe this should work as well: