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

LVL 15
Ess KayEntrapenuerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 inhouse one click program

@unknown_routine - i tried driveinfo, it doesnt work either

Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.