473,224 Members | 1,618 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

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 4580
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
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
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
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
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
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
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
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
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
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
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.