Question Question: File.Copy Proper Path Format for Copying Files from Remote Computer

Hopworks

Member
Joined
Mar 31, 2011
Messages
10
Programming Experience
5-10
I am working on some MySQL database supported applications for work using VB 2008 Express and everything is going smoothly except for one little thing I want to automate.

At work, I work on the applications on my laptop. When I get home, I work on those applications on my main desktop. What I would like to automate is copying the project files over to my desktop to work on them, then back to my laptop when I am finished.

As I do with ALL my network shares, the share I want to copy to and from on my laptop is protected. To do the file copying manually is simple enough... I click on the share from Windows Explorer, get prompted for a username and password, then passed that, I see the folder and I do my manual copying.

I would like to automate that with VB 2008 Express. Through Google searches, I've narrowed it down to importing system.io, and using file.copy. My problem is that what I read for passing the username and password is throwing a "The given path's format is not supported." error. Since I cannot find any guidelines for what the path must look like when passing a username and password, I cannot proceed.

Here is the code I am using. For obvious reasons, the sensitive stuff in the path is replaced with what that field represents.

I'm sorry if this is a silly question. I try to spend a few days googling for answers before reaching out for help here.

VB.NET:
Imports System
Imports System.IO
Public Class Form1

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		File.Copy("C:\test.rar", "\\username:password@machine_name\dsdapps\applications\dsdapps.laptop\dsdapps.laptop_042511.rar")
	End Sub
End Class
 
Back
Top