protected void Button1_Click(object sender, EventArgs e) { { //Kill the running program file foreach (var proc in Process.GetProcessesByName("test")) { proc.Kill(); } } try { //To Choose the path at server and c drive string fileName = "test.exe"; string sourcepath = @"\\192.168.5.10\fbar\TOOLS\"; string targetpath = @"c:\Test1\"; string sourcefile = System.IO.Path.Combine(sourcepath, fileName); string destfile = System.IO.Path.Combine(targetpath, fileName); //Create Test1 folder if it not created if (!System.IO.Directory.Exists(targetpath)) { System.IO.Directory.CreateDirectory(targetpath); } //Copy the .exe file from server to c drive { System.IO.File.Copy(sourcefile, destfile, true); } //Start the .exe file from c drive { System.Diagnostics.Process.Start(@"c:\Test1\test.exe"); } } catch (Exception) { //***Start this if file .exe cannot copy from server System.Diagnostics.Process.Start(@"c:\Test1\test.exe"); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)