|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Issue with using DOS commands in C#I am using following code
string src = "C:\Source"; string dest = "C:\Destination"; copyCmdStr = "XCOPY "+ src + " "+ dest; ProcessStartInfo processInfo = new ProcessStartInfo("CMD.Exe"); processInfo.Arguments = copyCmdStr; processInfo.UseShellExecute = false; processInfo.CreateNoWindow = true; Process.Start(processInfo); Nothing happens when this code is executed. Please help Ravichandra wrote:
> I am using following code My first question is why are you using xcopy from within a C# app to copy a > > string src = "C:\Source"; > string dest = "C:\Destination"; > copyCmdStr = "XCOPY "+ src + " "+ dest; > ProcessStartInfo processInfo = new ProcessStartInfo("CMD.Exe"); > processInfo.Arguments = copyCmdStr; > processInfo.UseShellExecute = false; > processInfo.CreateNoWindow = true; > Process.Start(processInfo); > > Nothing happens when this code is executed. Please help file? Go with System.IO.File.Copy(src, dest); and you're done. If those are directories, then get the files in the directory, create the target, then copy the files over. -- Tom Porterfield This is the first part of the code I am writing. In general, the
requirement is to support all the 20 odd switches of the Xcopy command. Tom Porterfield wrote: Show quoteHide quote > Ravichandra wrote: > > I am using following code > > > > string src = "C:\Source"; > > string dest = "C:\Destination"; > > copyCmdStr = "XCOPY "+ src + " "+ dest; > > ProcessStartInfo processInfo = new ProcessStartInfo("CMD.Exe"); > > processInfo.Arguments = copyCmdStr; > > processInfo.UseShellExecute = false; > > processInfo.CreateNoWindow = true; > > Process.Start(processInfo); > > > > Nothing happens when this code is executed. Please help > > My first question is why are you using xcopy from within a C# app to copy a > file? Go with System.IO.File.Copy(src, dest); and you're done. If those > are directories, then get the files in the directory, create the target, > then copy the files over. > -- > Tom Porterfield Ravichandra wrote:
> This is the first part of the code I am writing. In general, the Then simply make the two following changes:> requirement is to support all the 20 odd switches of the Xcopy command. //... copyCmdStr = src + " "+ dest; //... ProcessStartInfo processInfo = new ProcessStartInfo("xcopy.exe"); //... Or leave the processstartinfo as cmd.exe and change the copyCmdStr to "/c xcopy.exe " + src + " "+ dest; I would go with the former as xcopy is the real process you want to start, not cmd.exe. -- Tom Porterfield
call program windows in my application like a child
HttpWebRequest: black hole Screen Scrolling with Keyboard, cut, copy and past XML over GPRS - Is this a good idea????? TextBox Readonly OnPaint wrong font! Please help! BEEP while working Hi I want to Add to an existing xmLDocument an Element . How? I was searching around for a free C# profiler. Visual Studio® 2005 SP1 Error: The type or namespace name 'NLog' could not be found |
|||||||||||||||||||||||