Wednesday, January 28, 2009

How to Use Dos command(WithParameter) through C#

include following file

------------------------------------------------------------------

using System.Diagnostics;

using System.IO;

-------------------------------------------------------------------
On Button Click
------------------------------------------------------------------

ProcessStartInfo myStartInfo = new ProcessStartInfo();

myStartInfo.WorkingDirectory = @"c:\";

myStartInfo.FileName = @"c:\WINDOWS\system32\xcopy.exe";

myStartInfo.Arguments = @"c:\a.bat d:\temp\"; // give proper soucrce and
//destination path

myStartInfo.UseShellExecute = false;

Process myProcess = Process.Start(myStartInfo);