By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,247 Members | 1,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,247 IT Pros & Developers. It's quick & easy.

Accessing files and folders on remote server in webApplication

P: n/a
I got this problem for the web application

I try to access files on a remote server. string[] dirs = Directory.GetDirectories(@"E:\vehicles")
E drive is a map to a network drive. I get the DirectoryNotFoundException. How do I solve the problem or the is another way to write the code

Thank yo

Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
When you map a network drive, it is mapped for currently logged-on user and
is stored under HKEY_CURRENT_USER registry key. The mapped drive will
therefore be available only for that user. When your ASP.NET application is
run, it does not have access to the mapped drive because in its context it
does not exist.

In your case, you need to worry about security rather than mapping network
drives. When you run your ASP.NET application it is executed in context of
your local ASPNET account (unless you are running your application on domain
controller) which cannot be authenticated agains computers that host shared
folders (unless you try accessing your local shared folders on your
computer). In order to access network folders when no authentication can be
performed (your case) entity which is trying to access a resource is
identified as Guest account, which is probably disabled in your case (and
should remain so).

The best solution to your problem would be impersonating a domain account
(read ASP.NET Impersonation in MSDN) and then giving that account access to
the shared folder.

Another solution, although not recommended and avoided at all costs, would
be enabling guest account on network computer you are trying to access,
which will introduce more problems than it will solve. Stick to
impersonation, it is simple and poses no threats as long as you know how to
secure the access to the registry and your web server.

Hope this helps.

Regards,

--
Vjekoslav Babic, MCSA, MCDBA

"Z0gS" <an*******@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.com...
I got this problem for the web application:

I try to access files on a remote server. string[] dirs = Directory.GetDirectories(@"E:\vehicles"); E drive is a map to a network drive. I get the DirectoryNotFoundException. How do I solve the problem or the is another way to write the code?
Thank you

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.