Copying a Folder in vb.net to a specified place

i am using robocopy to copy directories from one mapped drive to another with...

Shell("C:\Windows\SysWow64\Robocopy.exe C:\upsdnc\11111 C:\ups\11111_dnc /E /Z /dcopy:T /fft /R:10 /ETA /log:C:\copy.log /tee")

now i need to create variables to plug in based on a selected path in a dialog.

so for instance...

Source: J:\mill\33000s\33200s\33283

Destination: I:\ups\jobs\33000s\33200s\33283_CompanyName\dnc

See, we have numerous job #s each which a corresponding folder on the other drive. i need to find a way for the destination path to be found based on the given source path. problem is the customer name throws a kink in things. the end of the source path (job#) will always match the job # on the destination path after the 5th "\" and up to the "_" so i suppose thats a start
knutter539Asked:
Who is Participating?
 
CodeCruiserCommented:
That's probably because you do not have a space after Robocopy.exe so it becomes

robocopy.exej:\mill\...

Similarly at the end of destfold

Shell("C:\Windows\SysWow64\Robocopy.exe " & srcFold & destFold & " /E /Z /dcopy:T /fft /R:10 /ETA /log:C:\copy.log /tee")
0
 
CodeCruiserCommented:
Something like below (untested)

Dim dest As String = "I:\ups\jobs\33000s\33200s\"
Dim src As String = "J:\mill\33000s\33200s\33283"
Dim srcFolder As String = src.substring(src.LastIndexOf("\") + 1)

dest &= srcFolder

Then loop through all the companies and keep adding to dest

Dim destFolder As String
foreach company as string in companies
    destFolder = dest & "_" & company & "\dnc"
    Shell(...)
Next
0
 
knutter539Author Commented:
well the company name is irrelevant to me in this situation. the "ups" drive is where our CAD models are stored and we include the company name. once its done and ready to go to the shop, it goes to "mill". we need to now send everything in the "mill" directory to be inside of "ups" before i send it all packaged to the archive drive.

so inside of "11111" on ups needs to be the corresponding mill folder with a _dnc added

start: "J:\mill\11000s\11100s\11111"

move to: "I:\ups\jobs\11000s\11100s\11111_Company\11111_dnc"

the code i can't work through is how the program knows to pass all that company crap and know based on the job# where to stick the mill directory.

i apologize if this system is confusing as hell
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
knutter539Author Commented:
So i have 2 browse dialogs and the first is to point to src and second is pointing to where its going.

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Dim srcFold As String = TextBox1.Text
        Dim destFold As String = TextBox2.Text

        Shell("C:\Windows\SysWow64\Robocopy.exe" & srcFold & destFold & "/E /Z /dcopy:T /fft /R:10 /ETA /log:C:\copy.log /tee")

says File Not Found though
0
 
knutter539Author Commented:
NOW im getting somewhere thank you! now it runs through but it only copies the files in mill to be inside of ups, it doesnt bring the folder itself inside of ups

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Dim srcFold As String = TextBox1.Text
        Dim destFold As String = TextBox2.Text
        MsgBox(srcFold)

        Shell("C:\Windows\SysWow64\Robocopy.exe" & " " & srcFold & " " & destFold & " " & "/E /Z /dcopy:T /fft /R:10 /ETA /log:C:\copy.log /tee")

^^^ Works for the files inside of the folder
0
 
CodeCruiserCommented:
That's a robocopy issue then. I have not used it so don't know about different switches.
0
 
knutter539Author Commented:
Ok so i have it working now to where it copies everything over except the parent directory. im accepting a solution to my original question though as it has been answered (thank you).

All i need to figure out now is why when i select the "1111" entire job over to the archive drive, it doesnt take the parent folder.

So with 11111_dnc in the "ups" drive the top folder is "11111_customer" which is step 1 done. i copy it to archive and it moves everything but doesnt bring "11111_customer" folder with it. possibly a setting in robocopy to take parent folder?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.