tkeeler1
asked on
Copy all Files and Folders in Visual Basic
Hi,
I'm trying to copy all files and folders in one directory to another directory. The problem is that "CopyFolder" also copies the original directory. I need to have all the files and folders to be copied to the root of the other directory. For instance, I need to copy everything in C:\MyStuff to the root of E:\ (without the MyStuff folder).
I have the following code:
Dim MyObj 'As New FileSystemObject
Set MyObj = CreateObject("Scripting.Fi leSystemOb ject")
If MyObj.FolderExists(startpa th) Then
MyObj.CopyFolder startpath, destpath
End If
But as I said, this method copies the "MyStuff" folder also, and not just the contents.
Any ideas?
Thank you,
TK
I'm trying to copy all files and folders in one directory to another directory. The problem is that "CopyFolder" also copies the original directory. I need to have all the files and folders to be copied to the root of the other directory. For instance, I need to copy everything in C:\MyStuff to the root of E:\ (without the MyStuff folder).
I have the following code:
Dim MyObj 'As New FileSystemObject
Set MyObj = CreateObject("Scripting.Fi
If MyObj.FolderExists(startpa
MyObj.CopyFolder startpath, destpath
End If
But as I said, this method copies the "MyStuff" folder also, and not just the contents.
Any ideas?
Thank you,
TK
ASKER
I can't use shell commands for my app. Can you do the same thing with a FileSystemObject?
Thanks,
TK
Thanks,
TK
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great! This works. Thanks a bunch iHadi.....
-TK
-TK
Your welcome tkeeler1
shell("xcopy c:\1 c:\2")
Copies everything from folder 1 into folder 2.
You may need to set some command line switches to handle sertain scenarios.
Hope this helps.
-Jim