Solved

Listing files on network drive

Posted on 2004-09-07
8
138 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now