Solved

Listing files on network drive

Posted on 2004-09-07
8
143 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
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

740 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