Link to home
Start Free TrialLog in
Avatar of knutter539
knutter539

asked on

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
SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of knutter539
knutter539

ASKER

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
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
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
That's a robocopy issue then. I have not used it so don't know about different switches.
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?