473,490 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

Dec 21 '06 #1
3 4584
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

Dec 21 '06 #2
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:
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
Dec 21 '06 #3
Ravichandra wrote:
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.
Then simply make the two following changes:

//...
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

Dec 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7363
by: David Gamble | last post by:
I am having problems with long timeouts when connecting to or executing commands in SQL Server 2000 SP3. I am writing an application that will be used on laptops within an environment that is...
0
373
by: Ravindran Pandian | last post by:
I have to add a "ATEStudio" popup menu in the VS IDE Menu Bar as below and the menu item "New Test Program" is having submenus like ( Csharp,VisualBasic,ManagedC++). ATEStudio >>NewTestProgram...
6
1485
by: Christopher Murtagh | last post by:
Greetings, I'm trying to create a user without create privileges and I don't seem to be able to do it. I could be clueless, but after my revoke statements, the new user still seems to be able to...
0
1340
by: Patrick Finnegan | last post by:
Running Versions 7.X and *.X on Windows 2000. We experienced very slow response times for some admin functions executed via the command line and the GUI. for example "db2 list tablespaces" was...
6
31127
by: Dario Di Bella | last post by:
Hi all, we have the following urgent issue affecting our development team. Initially we had one particular workstation that failed executing queries on a DB2 database, raising an invalid date...
3
1908
by: gmtonyhoyt | last post by:
Okay, this one's a tough one for me to explain so this might take a few e-mails to get the idea across. Here's what I got though. I have this application running on a Sun/Solaris machine,...
1
4828
by: Brad | last post by:
I have an issue trying to execute commands in a web service. The command starts under the specified user. However, it never completes its execution. I can execute simple commands like "echo HELLO"...
4
3207
by: Paul | last post by:
Hi, I've been struggling with this today, I'm developing a DotNet2.0 website in C# that needs to call a long running data query. Obviously this is a good candidate for an Asynchronous call, so...
13
2675
by: souissipro | last post by:
Hi, I have written a C program that does some of the functionalities mentionned in my previous topic posted some days ago. This shell should: 1- execute input commands from standard input,...
2
2210
by: kyosohma | last post by:
Hi, I was trying to hook into Google Calendar today using their gdata module for Python, but I can't seem to get Python to work with it. When I run the setup.py from the command line, I get the...
0
7108
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
272
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.