accessing network drive

  • Thread starter Abraham Andres Luna
  • Start date
A

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?
 
A

Abraham Andres Luna

found the answer:

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

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

Mark Rae

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...?
 
A

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
 
F

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top