Solved

Listing files on network drive

Posted on 2004-09-07
8
142 Views
Last Modified: 2010-04-23
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(Location)
            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
0
Comment
Question by:RySk8er30
  • 4
  • 3
8 Comments
 
LVL 8

Expert Comment

by:bramsquad
ID: 11999073
try using the file objects

        Dim file As FileInfo
        Dim dir As DirectoryInfo = New DirectoryInfo("G:/")

        For Each file In dir.GetFiles

        Next

~b
0
 

Author Comment

by:RySk8er30
ID: 11999516
Hi,

I still get an error:

Could not find a part of the path "G:\".

Any ideas?

Ryan
0
 
LVL 8

Expert Comment

by:bramsquad
ID: 12000838
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 41

Expert Comment

by:graye
ID: 12002559
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)
0
 

Author Comment

by:RySk8er30
ID: 12005456
Hi,

Even if I do look at the root of G:\ I get nothing.  I have verified that the path exists.

Ryan
0
 

Author Comment

by:RySk8er30
ID: 12005462
       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
0
 
LVL 8

Accepted Solution

by:
bramsquad earned 50 total points
ID: 12005993
dont know what to tell ya...

when i tried this code it worked for me (on a network drive)

when i put in an address that doesnt exist it gives me the error you got.

does this directory have access rights?
0
 

Author Comment

by:RySk8er30
ID: 12009260
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...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question