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

Copying Directories

I need to copy a directory to another locaiton. Is there some .Net
framework method I cannot find for copying a directory from 1 location to
another? I found the File.Copy(), but there does not seem to be a Directory
counterpart. Or do I have to code my own recrusion routine to do this?

TIA,

--
John C. Bowman
Software Engineer
Thermo Electron Scientific Instruments Div.
<Remove this before reply> jo*********@thermo.com
Nov 15 '05 #1
3 1957
John,

There is nothing in the framework to support this outright. You can
iterate through all the directories and sub directories in the directory,
and copy the items yourself.

Also, you might want to try the SHFileOperation API function. It will
allow you to copy a directory from one location to another. You will have
to call it through the P/Invoke layer.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John Bowman jo*********@thermo.com>" <<Remove this before reply> wrote in
message news:uB**************@TK2MSFTNGP12.phx.gbl...
I need to copy a directory to another locaiton. Is there some .Net
framework method I cannot find for copying a directory from 1 location to
another? I found the File.Copy(), but there does not seem to be a Directory counterpart. Or do I have to code my own recrusion routine to do this?

TIA,

--
John C. Bowman
Software Engineer
Thermo Electron Scientific Instruments Div.
<Remove this before reply> jo*********@thermo.com

Nov 15 '05 #2
"John Bowman" < wrote:
I need to copy a directory to another locaiton. Is there some .Net
framework method I cannot find for copying a directory from 1 location
to another? I found the File.Copy(), but there does not seem to be a
Directory counterpart. Or do I have to code my own recrusion routine
to do this?


This is off the top of my head, but it used to be that you could use the
Rename()-type functions to move directories... But it only worked if you
moved directories or files within the same drive.

Otherwise, just recreate the destination directory and loop to copy each
file.

--
gabriel
Nov 15 '05 #3
garbriel & nicholas,

Thanks for the help. I guessed I was going to have to code this up myself.

Cheers,

John

"gabriel" <no@no--spam.com> wrote in message
news:11***************************@msgid.meganewss ervers.com...
"John Bowman" < wrote:
I need to copy a directory to another locaiton. Is there some .Net
framework method I cannot find for copying a directory from 1 location
to another? I found the File.Copy(), but there does not seem to be a
Directory counterpart. Or do I have to code my own recrusion routine
to do this?


This is off the top of my head, but it used to be that you could use the
Rename()-type functions to move directories... But it only worked if you
moved directories or files within the same drive.

Otherwise, just recreate the destination directory and loop to copy each
file.

--
gabriel

Nov 15 '05 #4

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

Similar topics

8
by: Ram Baruch | last post by:
Hi, I'm trying to use the File.Copy() function. It works well when the desenation file is local (Like: C:\dest\dest.exe). The problem is that when I'm trying to copy to a destenation that starts...
4
by: Amos Soma | last post by:
Does anyone know the easiest way, in C#, to copy all directories and files starting with some root directory? For example, how might I copy all files and directories starting with 'C:\Program...
1
by: Framework fan | last post by:
Hello. If I created a .NET solution called say MySol, how can I make a copy of this *entire* solution (project folders, files, everything) and create a second copy of this somewhere else on my...
10
by: Martin Ho | last post by:
I am running into one really big problem. I wrote a script in vb.net to make a copy of folders and subfolder to another destination: - in 'from.txt' I specify which folders to copy - in...
0
by: bradford.bret | last post by:
Is there a way to use .NET to extract the directories and files out of a .zip file. I have a folder with many (hundreds) of .zip files, and since you can just open them in explorer and copy out...
2
by: Alan Bak | last post by:
HI I am running Active Perl on a Windows XP machine. I am hoping to get some advise on a strategy to monitor and copy files that are arriving in a directory and need to be copied to a second...
3
by: supriyamk | last post by:
Hi, I would like to know how to copy certain types of files from a group of directories into another group of directories.
4
by: supriyamk | last post by:
Hi, I am trying to search a directory for subdirectories, recreate the subdirectories elsewhere and copy only certain files from current subdirectory to new subdirectory. In other words i am...
1
by: skygremlin | last post by:
I am trying to write a simple VB app to copy all directories and files off a thumb drive to a directory on a pc. I have a couple things I am trying to automate. Final Build will: - Have...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.