I create one window application and as per user selection i create one batch file for copy files in one directory to another directory file is created but its not execute i don't know why? please help.
in code i user process class to execute batch file but its through exception at proc.start();
My code is:
Process proc = null;
string tempPath = @"C:\Users\jsolanki\Desktop\temp.bat";
StreamWriter sw = new StreamWriter(tempPath);
StringBuilder content = new StringBuilder();
foreach (string item in tempList)
{
content.Append(string.Format("Copy \"{0}\" \"{1}\\\" \r\n", item, destPath));
}
sw.WriteLine(content);
sw.Close();
string batDir = tempPath;
proc = new Process();
proc.StartInfo.WorkingDirectory = batDir;
proc.StartInfo.FileName = "temp.bat";
proc.StartInfo.CreateNoWindow = false;
proc.Start();
proc.WaitForExit();
MessageBox.Show("Copy is Complete");