lehmaj1
asked on
Is it possible in VB .Net to use XCOPY with VB variables
I am just wondering how I would add Visual Basic variables (folder path) to a xcopy command in visual basic .net. I have the code that I have attempted to use. I have also commented out a few ideas that I tried, but didnt work. I am trying to get around the issue of copying the documents folder in Vista. Those legacy folders for "My Videos, My Pictures, etc" are casuing problems copying that folder. Any suggestions would be helpful.
Thanks,
Joe
Thanks,
Joe
Dim local_users As String
' Here is where we loop through the selected items in the listbox.
For Each local_users In lstUsers.SelectedItems
' We need to formulate the full path again to test if it exists and to copy the file.
'If File.Exists("c:\users\" & theSelectedFile) Then
' Here we do a simple file.copy call where we specify the file we want and then
' specify the destination where we want to go. We let the user know each file that was
' copied as well.
Dim objShell As Object
objShell = CreateObject("WScript.Shell")
Dim path1 As String
Dim path2 As String
path1 = ("C:\Users\" & local_users & "\Documents")
path2 = (FolderChoiceTextBox.Text & "\" & local_users & "\Documents")
My.Computer.FileSystem.CopyDirectory("c:\users\" & local_users & "\Desktop", FolderChoiceTextBox.Text & "\" & local_users & "\Desktop")
My.Computer.FileSystem.CopyDirectory("c:\users\" & local_users & "\Favorites", FolderChoiceTextBox.Text & "\" & local_users & "\Favorites")
My.Computer.FileSystem.CopyDirectory("c:\users\" & local_users & "\Music", FolderChoiceTextBox.Text & "\" & local_users & "\Music")
My.Computer.FileSystem.CopyDirectory("c:\users\" & local_users & "\Pictures", FolderChoiceTextBox.Text & "\" & local_users & "\Pictures")
'objShell.run("xcopy c:\users\" & theSelectedFile & "\Documents", FolderChoiceTextBox.Text & "\" & theSelectedFile & "\Documents")
Shell("xcopy" & path1, path2)
MessageBox.Show("Copied: " & local_users)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.