accessing network drive

Discussion in 'ASP .Net' started by Abraham Andres Luna, Oct 14, 2005.

1. Abraham Andres LunaGuest

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:

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?

Abraham Andres Luna, Oct 14, 2005

2. Abraham Andres LunaGuest

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

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

"Abraham Andres Luna" <> wrote in message
news:...
> 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:
>
>
> 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?
>

Abraham Andres Luna, Oct 14, 2005

3. Mark RaeGuest

"Abraham Andres Luna" <> wrote in message
news:ex0$... > 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...? Mark Rae, Oct 14, 2005 4. Abraham Andres LunaGuest 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 "Mark Rae" <> wrote in message news:... > "Abraham Andres Luna" <> wrote in message > news:ex0$...
>
>>
>> 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...?
>

Abraham Andres Luna, Oct 14, 2005
5. Mark RaeGuest

"Abraham Andres Luna" <> wrote in message
news:%...

>i do have the drive mapped

Mark Rae, Oct 14, 2005
6. FoundThisOnlineGuest

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.

FoundThisOnline, Oct 14, 2005