[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

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
0
knutter539
Asked:
knutter539
  • 4
  • 3
2 Solutions
 
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
 
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
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
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
 
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now