Home All Groups Group Topic Archive Search About
Author
14 Oct 2005 3:32 PM
Abraham Andres Luna
hey everyone,

i try to access a network drive using asp.net:

File.Delete(@"W:\text.txt");

but i get this error message:

System.IO.DirectoryNotFoundException: Could not find a part of the path
'W:\text.txt'.

i setup impersonate in the web.config:

<identity impersonate="true" userName="user" password="password" />

but it still doesnt work. this user has access to the network drive. i can
access it using windows explorer. do i have to impersonate this user in the
code and then access the drive?

Author
14 Oct 2005 3:45 PM
Abraham Andres Luna
found the answer:

File.Delete(@\\servername\folder\text.txt);

this works fine. does anyone know why the other method failed



Show quoteHide quote
"Abraham Andres Luna" <a**@rdk.com> wrote in message
news:O7XJJSN0FHA.560@TK2MSFTNGP12.phx.gbl...
> hey everyone,
>
> i try to access a network drive using asp.net:
>
> File.Delete(@"W:\text.txt");
>
> but i get this error message:
>
> System.IO.DirectoryNotFoundException: Could not find a part of the path
> 'W:\text.txt'.
>
> i setup impersonate in the web.config:
>
> <identity impersonate="true" userName="user" password="password" />
>
> but it still doesnt work. this user has access to the network drive. i can
> access it using windows explorer. do i have to impersonate this user in
> the code and then access the drive?
>
Are all your drivers up to date? click for free checkup

Author
14 Oct 2005 5:12 PM
Mark Rae
"Abraham Andres Luna" <a**@rdk.com> wrote in message
news:ex0$PZN0FHA.2212@TK2MSFTNGP15.phx.gbl...

> found the answer:
>
> File.Delete(@\\servername\folder\text.txt);
>
> this works fine. does anyone know why the other method failed

Er, because the webserver doesn't have a mapped W: drive...?
Author
14 Oct 2005 8:06 PM
Abraham Andres Luna
i do have the drive mapped
i can use windows explorer and under my computer i have a W: that is mapped
to \\servername\folder

Show quoteHide quote
"Mark Rae" <m***@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:uY1asJO0FHA.464@TK2MSFTNGP15.phx.gbl...
> "Abraham Andres Luna" <a**@rdk.com> wrote in message
> news:ex0$PZN0FHA.2212@TK2MSFTNGP15.phx.gbl...
>
>> found the answer:
>>
>> File.Delete(@\\servername\folder\text.txt);
>>
>> this works fine. does anyone know why the other method failed
>
> Er, because the webserver doesn't have a mapped W: drive...?
>
Author
14 Oct 2005 8:47 PM
Mark Rae
"Abraham Andres Luna" <a**@rdk.com> wrote in message
news:%239qHKrP0FHA.2932@TK2MSFTNGP10.phx.gbl...

>i do have the drive mapped

Yes, but does your webserver...?
Author
14 Oct 2005 9:40 PM
FoundThisOnline
When you do anything with a mapped drive, it actually is looking up the
directory with your default built-in "ASPNET" local account in that
machine.  By default, that account has no access to the network drive
and the only way to do it is to change that in the machine.config file.



Post Thread options