accessing directory over network

RTT

Newcomer
Joined
Mar 18, 2005
Messages
19
working with folders and files

i want to create an application to search files on a server. But i don't
know where to start. is there anyone who has code that he or she is willing
to share? I'm searching for code to search files with a specific extension.

I think to main problem is that the directory's i want to search are on an
computer in the network and i should reach them as
\\computername\directory\.... also i should be able to read those
directory's as a specific user. So how can i read in a directory over the
network while authentication with a specific username?

kind regards
 
Last edited:
I can access a directory with this code.



Code:
Dim strPath As String = "\\be0001\Users\josgijsens"

'Dim strPath As String = "c:\"

Dim strFile, strDir As String

For Each strDir In Directory.GetDirectories(strPath)

 RichTextBox1.AppendText(Path.GetFileName(strDir) & vbCrLf)

Next

For Each strFile In Directory.GetFiles(strPath)

RichTextBox1.AppendText(Path.GetFileName(strFile).ToString & vbCrLf)

Next



with this code i can read the directories and files on my harddisks or on an network directory "\\be0001\Users\josgijsens".



My current problem is that i'm the user with rights on "\\be0001\Users\josgijsens" but if i want to view an other folder "\\be0001\Users\markwouters" i don't have the rights to is. I should be able to acces the folder as a different user. so before i try to access it i should somehow make sure that i access it not as the user that run the code but as a user given in codebased with rights to all folders. is that possible?



second question. you can search a folder with GetFiles(strPath, "*.mp3") but that will only search in de current path and not in the subfolders. is there a way to search a complete map including subfolder? of will i have to write my recursive method myself?



thxs
 
Back
Top