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

file copy questions


....hope this question is on the right ng.

The code below works to copy all files and folders from D:\Template to a new
location that is specified by the user.
Is there any easy way to modify this code to copy everything except for one
or two child folders inside of D:\Template ?
....or would I have to copy everything and then delete the folders I don't
want copied over? (in other words, I want to copy everything but
D:\template\folder1 and D:\template\folder2 ) ...and I won't know all
file and folder name within D:\Template in advance, so I can't simply list
each specifically, but I will know the names of the folders that I don't
want copied.

thanks
Jeff

Dim fso

Dim sourcefolder As String, destinationfolder As String

sourcefolder = "D:\Template"

destinationfolder = "D:\" & LbDbNames.SelectedItem

fso = CreateObject("Scripting.FileSystemObject")

fso.CopyFolder(sourcefolder, destinationfolder)



--
Posted via a free Usenet account from http://www.teranews.com

Jan 30 '08 #1
2 1301
"Jeff" <no****@george.comwrote in
news:47***********************@free.teranews.com:
>
...hope this question is on the right ng.

The code below works to copy all files and folders from D:\Template to
a new location that is specified by the user.
Is there any easy way to modify this code to copy everything except
for one or two child folders inside of D:\Template ?
Nope, unfortunately .NET's file copy doensn't have the ability to include
exclusions
...or would I have to copy everything and then delete the folders I
don't want copied over? (in other words, I want to copy everything but
D:\template\folder1 and D:\template\folder2 ) ...and I won't know
all file and folder name within D:\Template in advance, so I can't
simply list each specifically, but I will know the names of the
folders that I don't want copied.
Or you can loop through all the folders and only copy valid folders over.


--
sp**********@rogers.com (Do not e-mail)
Jan 30 '08 #2
On Jan 30, 8:17 pm, "Jeff" <no_...@george.comwrote:
...hope this question is on the right ng.

The code below works to copy all files and folders from D:\Template to a new
location that is specified by the user.
Is there any easy way to modify this code to copy everything except for one
or two child folders inside of D:\Template ?
...or would I have to copy everything and then delete the folders I don't
want copied over? (in other words, I want to copy everything but
D:\template\folder1 and D:\template\folder2 ) ...and I won't know all
file and folder name within D:\Template in advance, so I can't simply list
each specifically, but I will know the names of the folders that I don't
want copied.

thanks
Jeff

Dim fso

Dim sourcefolder As String, destinationfolder As String

sourcefolder = "D:\Template"

destinationfolder = "D:\" & LbDbNames.SelectedItem

fso = CreateObject("Scripting.FileSystemObject")

fso.CopyFolder(sourcefolder, destinationfolder)

--
Posted via a free Usenet account fromhttp://www.teranews.com
Single codeline can copy files:
My.Computer.FileSystem.CopyFile(<source>, <destination>)

And delete unwanted files as Cor replied:
My.Computer.FileSystem.Deletefile(<path>)

Hope this helps...
Jan 31 '08 #3

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

Similar topics

48
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential...
1
by: Tony George | last post by:
Hi, I'm having a problem using the Copy module on a ClearCase view that's been set as "readonly" (i.e. ct chview -readonly <view tag>). I want to copy a file out of this view and put it in...
0
by: Tess | last post by:
Hi, Long time reader, first time poster... Any help is appreciated. I have a few questions regarding Winform controls embedded within an html page. For more info please see the appendix. Now,...
2
by: Greg | last post by:
looking for an easy way for users to browse for a file on their local drive, and then have access automatically make a copy of that file (files will most likely be images) and save it under a new...
4
by: Grant Austin | last post by:
Hello, This might be a tad off topic. The c-programming groups I found appear to be unused... The problem is simple... I need to create a listing file from an assembler source file. The...
8
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
1
by: annamanthadoo | last post by:
can anyone help me i need to copy a file (.txt) from a client to a sever in C#
12
by: dbuchanan | last post by:
Hello, (Is this the proper newsgroup?) === Background === I am building a solution with two projects. One project is my data access layer which contains my DataSet as an xsd file. The XSD...
9
by: fniles | last post by:
I would like to copy a table(s) from SQL Server 2005 to a CVS file and vice versa. I was thinking to use the BCP command line utility, but I have a few questions: 1. The machine where I am...
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
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
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
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.