473,396 Members | 2,129 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.

Copying All Contents of One Folder into another

How would I copy all the contents of one folder (Including all subfolders +
files) in VB.NET? Could you please provide source code or step by step
instructions (I'm only a novice)

-Jason

Nov 20 '05 #1
4 9447
Hi Jason

See directorymove in this folder
http://msdn.microsoft.com/library/de...classtopic.asp

There is not command as Xcopy in VB.net, you have to loop through all
folders and when it is moving you have to do that recursivly however that
is not really beginners stuff.

(Or try a commandline command which I really do not know if it works however
you can try it using)

\\\
Dim p As New Process
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = False
p.StartInfo.Arguments = "\?"
p.StartInfo.WorkingDirectory = "C:\mydir"
p.StartInfo.FileName = "myProg.exe"
p.Start()
///

I hope this helps,

Cor
Nov 20 '05 #2
How about something like this.

Public Sub CopyDirectory(ByVal strSrc As String, ByVal strDest As String)
Dim dirInfo As New System.IO.DirectoryInfo(strSrc)
Dim fsInfo As System.IO.FileSystemInfo

If Not System.IO.Directory.Exists(strDest) Then
System.IO.Directory.CreateDirectory(strDest)
End If

For Each fsInfo In dirInfo.GetFileSystemInfos
Dim strDestFileName As String = System.IO.Path.Combine(strDest,
fsInfo.Name)

If TypeOf fsInfo Is System.IO.FileInfo Then
System.IO.File.Copy(fsInfo.FullName, strDestFileName, True)
'This will overwrite files that already exist
Else
CopyDirectory(fsInfo.FullName, strDestFileName)
End If

Next

End Sub

"Jason Moss" <pc******@sbcglobal.net> wrote in message
news:OU**************@TK2MSFTNGP12.phx.gbl...
How would I copy all the contents of one folder (Including all subfolders + files) in VB.NET? Could you please provide source code or step by step
instructions (I'm only a novice)

-Jason

Nov 20 '05 #3
* "Jason Moss" <pc******@sbcglobal.net> scripsit:
How would I copy all the contents of one folder (Including all subfolders +
files) in VB.NET? Could you please provide source code or step by step
instructions (I'm only a novice)


<URL:http://www.google.de/groups?as_q=copy+directory+languages.vb>

;-)

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
Jason did you get the email ?
"Jason Moss" <pc******@sbcglobal.net> wrote in message
news:OU**************@TK2MSFTNGP12.phx.gbl...
How would I copy all the contents of one folder (Including all subfolders + files) in VB.NET? Could you please provide source code or step by step
instructions (I'm only a novice)

-Jason

Nov 20 '05 #5

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

Similar topics

3
by: Raghul | last post by:
hi I am having a problem. I want to copy a file from the folder and paste it or move it to another folder. Is it possible in python? Actually I need to implement this in the zope for my site. When...
3
by: 21novembre | last post by:
Hi all, I made a question several days before to describe my strange trouble of mysqldump. But I still can't figour it out. Well, I just want to ask another question whether I could just backup...
5
by: TB | last post by:
Hi All: This news group is proving to be great help on my path towards mastering ASP.NET thanks to all of you helpful souls out there. I am looking forward to the day when I can contribute...
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...
4
by: tshad | last post by:
I have an old version of VS 2002 and want to make a copy of my Visual Studio project to another project with another name. In VS 2003, you can do it but there is no copy project command in VS 2002...
4
by: Jeff | last post by:
Is there a way, to make a page that gets info from a DB using scripting. then take that page, and copy it to another folder, BUT, not having the script there. making it become all html? so the...
6
by: andrew.varley | last post by:
HI All, I am trying to make a small program that will copy the contents of one folder into another folder automatically. This is for backup and i want to just be able to run the program and...
9
by: Jess | last post by:
Hello, I tried to clear a vector "v" using "v.clear()". If "v" contains those objects that are non-built-in (e.g. string), then "clear()" can indeed remove all contents. However, if "v"...
13
by: writeson | last post by:
Hi all, I'm writing some code that monitors a directory for the appearance of files from a workflow. When those files appear I write a command file to a device that tells the device how to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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.