473,666 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\fol der1 and D:\template\fol der2 ) ...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, destinationfold er As String

sourcefolder = "D:\Templat e"

destinationfold er = "D:\" & LbDbNames.Selec tedItem

fso = CreateObject("S cripting.FileSy stemObject")

fso.CopyFolder( sourcefolder, destinationfold er)



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

Jan 30 '08 #1
2 1330
"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\fol der1 and D:\template\fol der2 ) ...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**********@ro gers.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\fol der1 and D:\template\fol der2 ) ...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, destinationfold er As String

sourcefolder = "D:\Templat e"

destinationfold er = "D:\" & LbDbNames.Selec tedItem

fso = CreateObject("S cripting.FileSy stemObject")

fso.CopyFolder( sourcefolder, destinationfold er)

--
Posted via a free Usenet account fromhttp://www.teranews.co m
Single codeline can copy files:
My.Computer.Fil eSystem.CopyFil e(<source>, <destination> )

And delete unwanted files as Cor replied:
My.Computer.Fil eSystem.Deletef ile(<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
8470
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 problem. The program may crash unexpectedly while writing to the file. If so, my program should detect this during startup, and then (during startup) probably delete the data added to the file and redo the writing operation.
1
4316
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 another directory that's outside of ClearCase. The strange thing is that the copy command actually copies correctly. The problem is that it returns a "0" errorcode because of the fact that the view is readonly. I guess "copy" still tries to write...
0
2588
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, for the questions. 1. A button on my control executes the System.IO.Directory.GetDirectories funtion (the scanned directory resides on the hosting web server). What credentials is this
2
9346
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 name (somehow relating it to the PK of the main table) in a directory on the server where the DB is stored... i realize that might not be the best wording of what im trying to do, so ill try explaining it a lil differently. each record created...
4
1533
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 listing file is just a copy of the source file with line numbers along with a list of syntax errors (e.g. multiply or undefined symbols).
8
9744
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 problem: my vb.net program has problems with UNC. If the UNC server is restarted or goes off-line, my VB.net program crashes. The code for UNC access to the file is included below and is put in the tick event of a form timer control running every...
1
7835
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
13427
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 file was built by draging tables from the Data Sources pane. Auto-generated code created the files associated wtih the XSD file (xss,
9
15139
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 going to run BCP utility does not have SQL Server installed, so BCP.exe and its underlying DLLs are not there. I copied BCP.EXE, then it tells me that it expects sqlncli.dll. After I copied that DLL, it now says "Unable to load BCP resource DLL. BCP...
0
8443
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8866
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7385
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.