Reputation: 2187
I am trying to get:
Directory.Exists(@"E:\subdirectory")
to return "true" when running from ASP.NET when E: is a persistent mapped network drive. I used the following command to map it from a command line running under the context of my user, which returns successfully and does not prompt for credentials:
net use E: \\servername\sharename /persistent:yes
At this point I'm running entirely locally.
When I run the Directory.Exists line from a console app or linqpad, it returns true. When I run this from an ASP.NET application running under IIS (not IIS express), it returns false.
I have changed my application pool to use the same user account I run as locally. I've verified this has taken effect by:
However, my ASP.NET application still returns false when checking for the network share.
Why is this?
Upvotes: 1
Views: 1723
Reputation: 127603
Mapped network drives are tied to the user session. IIS is running in session 0, your mapped drive is running in most likely session 1.
I don't know of any way to make network drives show up for other sessions when you create them for your session, I think you will need to not use E:\
and instead use \\servername\sharename
for the path.
Upvotes: 1