473,322 Members | 1,403 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,322 software developers and data experts.

XCopy in .NET

Is there a Platform way to grab an entire directory and copy it? Or
will I have to iterate through the files and binary write them?

Thanks

BLink
Brian Link in St. Paul
----------------------
"Just because we have chiseled abs and stunning features,
doesn't mean that we too can't not die in a freak gasoline fight
accident."
Jul 21 '05 #1
2 6435
If you prefer to use P/Invoke, it would be best that you change the title of
the post to "XCopy in P/Invoke".

To achieve XCopy in .Net, we may need to enumerate the contents of the
directory by using Directory.GetFiles() and Directory.GetDirectories(). Then
use FileCopy() to copy the files one by one.

Alternatively, we can use the following:

using System.Diagnostics;

ProcessStartInfo p = new ProcessStartInfo("xcopy");
p.Arguments = "/s c:\source c:\dest";
p.CreateNoWindow = true;
Process.Start(p);

I hope this helps.
--
Regards,

Felix Wang

"Brian Link" <bl***@visi.com> wrote in message
news:go********************************@4ax.com...
Is there a Platform way to grab an entire directory and copy it? Or
will I have to iterate through the files and binary write them?

Thanks

BLink
Brian Link in St. Paul
----------------------
"Just because we have chiseled abs and stunning features,
doesn't mean that we too can't not die in a freak gasoline fight
accident."

Jul 21 '05 #2
Hello Brian,

Thanks for your post. As I understand, you want to copy a directory
directly without enumerating and copying each file and sub-folder. Please
correct me if there is any misunderstanding.

1. We are able to use the SHFileOperation() API to xcopy a directory.
Please refer to the following articles and sample:

SHFileOperation Function
http://msdn.microsoft.com/library/de...us/shellcc/pla
tform/shell/reference/functions/shfileoperation.asp

http://www.visualbasicforum.com/t125205.html

2. Since SHFileOperation() is unmanaged API, you may need to use P/Invoke
to call it from within your .NET app:

Consuming Unmanaged DLL Functions
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconconsumingunmanageddllfunctions.asp

3. I'd like to provide the following sample in case you will need to copy a
directory by iterating through the files in .NET:

Function to copy a directory to another place
http://www.codeproject.com/csharp/co...srecursive.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #3

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

Similar topics

6
by: xo55ox | last post by:
After setting up the linked server connection at the standby server, I tried to xcopy a file through the sql server 2000 schedule task to the standby server's shared directory. But it keeps giving...
3
by: Ryno Rijnsburger | last post by:
I am busy packaging our product as a standard Setup project in VS.NET that uses a bunch of merge modules (basically, a merge module for every key infrastructure component in our system). Part...
6
by: Zeya | last post by:
I am developing a ASP.Net(Web) based deployment tool, which requires XCOPY functionality. Here is the code for the method: public static int ExecuteProcess ( string ProcessName, string...
2
by: Bruce Schechter | last post by:
Whereas Microsoft highlights the concept of "xcopy deployment" for .NET applications, I gather that it is not necessarily possible to move an ASP.NET application from one computer to another via...
2
by: Grigs | last post by:
Hello, I am attempting to write a Web Method in my Web Service that starts a process that runs the XCOPY command with passed in parameters. It is failing on me through code. However, if I take...
5
by: Volker Jobst | last post by:
Hi. I have this code: Dim p As New Process Dim info As New ProcessStartInfo Dim sa As New ArrayList Dim s As String Try With info
1
by: lizii | last post by:
At the moment my company have asked me to look into installations. We use pure .NET applications and although i have looked into installer programs (installshield...wise..etc) none of them are...
1
by: vinayakkatkam | last post by:
public bool ProcessXCopy() { string XCopyArguments = "C:\\Documents and Settings\\Vinayak.Katkam\\Desktop\\SYNCHRONIZATION\\BASE-VERSION\\SDDS\\*.* " + "C:\\Documents and...
1
by: Dave | last post by:
I'm trying to do the following xcopy from my Windows installer and it doesn't work. I even tried running the installer as user with credentials instead of LocalService. I'm running in 2003Server,...
3
by: Liz | last post by:
I was intending to use an XCOPY install for a VS2005 C# WinForms app but when I copied the files and ran the app on a clean machine it failed when it needed Crystal Reports. Can you not use XCOPY...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.