How can I specify login information within VB.Net code to allow my app to access directories/folders on another server?
Posted on 2008-10-30
I have the following code:
Public Class Form1
Dim FullPath As String = "\\MyServer\C$"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Public Sub ListSubDirectories(ByVal FullPath As String)
Dim currDirectory As New IO.DirectoryInfo(FullPath)
For Each subDirectory As IO.DirectoryInfo In currDirectory.GetDirectories
If I specify the FullPath to be the PC I am working on, there are no issues because I am already logged in obviously. If I specify FullPath as another server, it will list the initially directory I specified, but will go no further. I receive an error message:
IOException was unhandled
Logon failure: unknown user name or bad password.
I would just like to know how to specify username and password within app. My ultimate goal is to create an app which will copy/backup specified folders/directories from specified server to another network resource, ie; another PC, Networked Hard Drive, etc.
Thanks in advance.