Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Copying Folders With All Contents
Author:
Theodore DiNozzo
E-mail:
Click to e-mail author
Submitted:
7/17/2011
Version:
VB 2010
Compatibility:
VB 2010
Category:
File Manipulation
Views:
12418
Copying Folders With All Contents Including Other Folders. VB.net 2010 does not have a built in code to copy full folders with their contents but olny files(one by one)!!! So I created my own code to do that.
Declarations:
Imports System.IO
Code:
Module Logic Public Function CopyDirectory(ByVal Src As String, ByVal Dest As String) CopyDirectory = False If Not Directory.Exists(Src) Then CopyDirectory = "%%SRCNOTEXITS%%" Exit Function End If If Dest.Substring(Dest.Length - 1, 1) <> Path.DirectorySeparatorChar Then Dest += Path.DirectorySeparatorChar End If If Not Directory.Exists(Dest) Then Directory.CreateDirectory(Dest) Dim Files As String() Files = Directory.GetFileSystemEntries(Src) Dim element As String For Each element In Files If Directory.Exists(element) Then CopyDirectory(element, Dest & Path.GetFileName(element)) Else File.Copy(element, Dest & Path.GetFileName(element), True) End If Next Return True End Function End Module
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement