473,396 Members | 2,002 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,396 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 6436
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.