Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Folder on a Mapped Network Drive

Status
Not open for further replies.

yu217171

Programmer
Aug 2, 2002
203
CA
Hi everyone,

I'm having problems creating a folder on a mapped network drive. The code works fine for a local drive but I get the following error when attempting to run the code on a mapped drive.

Error: Could not find a part of the path "R:\".

Here's a snippet of the code that I am using.

Code:
DirectoryInfo objFolder = new DirectoryInfo ("R:\\Test");
objFolder.Create ();

Anyone have any ideas or come across this problem before?

Keith
 
I've never tried this myself but its bound to be a permissions problem. When you map a network drive it is common practice to specify a domain account to access that location with. If this is not the account your asp.net application is running under you may have problems. By default this will be the MACHINENAME/ASPNET account. As this is a local account it won't have any network privileges. You can impersonate a different account in the web.config like this..

<identity impersonate="true" userName="domain/account" password="password" />

If you are alreayd doing this make sure the impersonated account has suitable windows security privelegs on the location you are trying to write to.

HTH

Rob

Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
 
Hi Rob,

Thanks for the fast reply. That did it! I keep forgetting that the ASPNET account is not a domain user account. Thanks for the heads up.

Keith
 
Sorry Rob,

I lied. It works great if you're sitting at the server and running the code. It does NOT work if you're viewing the page remotely =( But impersonation is on ...

Any insight? =)

Keith
 
Are you specifying the account to impersonate? If you don't do this it will take the windows user account of the authenticated client user. Maybe this is different between the server and the remote client?

I'm not on the network right now so can't test anything to see if I can do this remotely...

Rob

Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
 
Hi Rob,

I have impersonation on and using my domain account and username as the account to impersonate with. I still get the error

Could not find a part of the path "M:\".

M:\ is a mapped folder on my desktop (I'm testing from my laptop) with full control permissions for everyone.

Keith
 
Instead of using a mapped path, I used a UNC path to refer to my folder and it worked well. The problem I was having seemed to be with impersonation. I had to specify a domain user account and a password in my web.config file. What I didn't understand was, why wasn't it picking up my Windows account credentials?

<identity impersonate="true" userName="domain\account" password="mypwd" />

The user account I specified in my web.config is the exact same one that I use to login.

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top