RySk8er30
asked on
Listing files on network drive
Hi,
How can I list files on a network drive? I tried this...
Dim Location As String = "G:\SHARE\ALL\Document Control\" & Request.QueryString("type" )
If Directory.Exists(Location) Then
Dim files As Object = Directory.GetFiles(Locatio n)
Dim file As String
For Each file In files
lblError.Text += file & ","
Next
End If
but it doesn't work. I can see local files fine, but when I try to see a networked drive it has problems.
Ryan
How can I list files on a network drive? I tried this...
Dim Location As String = "G:\SHARE\ALL\Document Control\" & Request.QueryString("type"
If Directory.Exists(Location)
Dim files As Object = Directory.GetFiles(Locatio
Dim file As String
For Each file In files
lblError.Text += file & ","
Next
End If
but it doesn't work. I can see local files fine, but when I try to see a networked drive it has problems.
Ryan
ASKER
Hi,
I still get an error:
Could not find a part of the path "G:\".
Any ideas?
Ryan
I still get an error:
Could not find a part of the path "G:\".
Any ideas?
Ryan
its becuase its not finding what path you gave it
you want to change my code to work with yours
if you have this line...
If Directory.Exists(Location) Then
then this line
Dim dir As DirectoryInfo = New DirectoryInfo(Location)
should work
~~im assuming that you just have to change "G:/" to your variable Location
you want to change my code to work with yours
if you have this line...
If Directory.Exists(Location)
then this line
Dim dir As DirectoryInfo = New DirectoryInfo(Location)
should work
~~im assuming that you just have to change "G:/" to your variable Location
Both the Directory.Exist() method and the Directory.Files() method expect a fully-formed path... no wildcards or anything else tacked on to the end.
I presume that you have verified that you have mapped the network drive correctly, and can see files in that path? (Open a command prompt and do a "dir " and paste the path string onto the line, then hit enter)
I presume that you have verified that you have mapped the network drive correctly, and can see files in that path? (Open a command prompt and do a "dir " and paste the path string onto the line, then hit enter)
ASKER
Hi,
Even if I do look at the root of G:\ I get nothing. I have verified that the path exists.
Ryan
Even if I do look at the root of G:\ I get nothing. I have verified that the path exists.
Ryan
ASKER
Dim Location As String = "G:\" 'SHARE\ALL\Document Control\" & Request.QueryString("type" )
Dim file As FileInfo
Dim dir As DirectoryInfo = New DirectoryInfo(Location)
For Each file In dir.GetFiles()
lblError.Text += Convert.ToString(file) & ", "
Next
Dim file As FileInfo
Dim dir As DirectoryInfo = New DirectoryInfo(Location)
For Each file In dir.GetFiles()
lblError.Text += Convert.ToString(file) & ", "
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well this is a drive mapped to a Novell server. The user who is logged into the web server is the administrator so he has access to all the Novell directories...
Dim file As FileInfo
Dim dir As DirectoryInfo = New DirectoryInfo("G:/")
For Each file In dir.GetFiles
Next
~b