• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

System.IO in VS2010 error when attempting to access mapped drive

I have a program which has a function to find all files in a selected folder

It gives me an error when i use mapped network drives

drives not found
Running the debugger, i noticed the drives do not even exist but they are visable in my computer

network drives

Please help, need this fixed asap.

here is the code i use

Using System.IO

sub blah(rootDir as string)
 Dim files = From file In My.Computer.FileSystem.GetFiles(rootDir, FileIO.SearchOption.SearchTopLevelOnly) _
            Order By file _
               Select My.Computer.FileSystem.GetFileInfo(file)
end sub

Open in new window

Ess Kay
Ess Kay
1 Solution
Craig WagnerSoftware ArchitectCommented:
I just tried pasting your code into a new project and accessing one of my mapped network drives. It worked fine. What type of application is this? Is it a web application or a Windows service? If so, it's running under a different user context and won't have access to the drives that are mapped under your user context.
You are using My.Computer and network drives are not part of this.

instead try;

dim allDrives() as DriveInfo= DriveInfo.GetDrives()

I tested this. allDrives() will contain all of my mapped drives.
Ess KayEntrapenuerAuthor Commented:
@CraigWagner - its a regular vb.net inhouse one click program

@unknown_routine - i tried driveinfo, it doesnt work either

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Ess KayEntrapenuerAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for esskayb2d's comment #a39588512

for the following reason:

Solved it myself

I ran

Apparently i was impersonating a different user which is not Admin and did not have access to the drives.
David Johnson, CD, MVPOwnerCommented:
Ess KayEntrapenuerAuthor Commented:
thanks, Was impersonating a user with no access
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now