Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Listing files on network drive

Posted on 2004-09-07
8
Medium Priority
?
147 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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 100 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

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!

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

604 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