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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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
 
If your code is like here :
Code:
DirectoryInfo objFolder = new DirectoryInfo ("R:\\Test");
try
{
   objFolder.Create ();

}
catch (Exception ex)
{
  string sErr = ex.GetType() + " " + ex.Message;
}
then
DirectoryInfo objFolder = new DirectoryInfo ("R:\\Test");
there is no checking about the path passed in the constructor.
The error is thrown when Create() is called and that because :
1. the "R:\\" doesn't exist on the machine where your code is running
or
2. If the "R:\\" drive is mapped then maybe it is readonly and you cannot create files on that drive.
To check that, use notepad and try to create a file on that drive.

-obislavu-
 
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