accessing network drive

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

  1. 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?
    Abraham Andres Luna, Oct 14, 2005
    #1
    1. Advertising

  2. found the answer:

    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:
    >
    > <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?
    >
    Abraham Andres Luna, Oct 14, 2005
    #2
    1. Advertising

  3. Abraham Andres Luna

    Mark Rae Guest

    "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
    #3
  4. 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$...
    >
    >> 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...?
    >
    Abraham Andres Luna, Oct 14, 2005
    #4
  5. Abraham Andres Luna

    Mark Rae Guest

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

    >i do have the drive mapped


    Yes, but does your webserver...?
    Mark Rae, Oct 14, 2005
    #5
  6. 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
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon
    Replies:
    5
    Views:
    11,133
    Scott M.
    Jan 17, 2010
  2. =?Utf-8?B?ZG90bmV0dGVzdGVy?=

    Accessing NETWORK Drive through ASPNET_USER

    =?Utf-8?B?ZG90bmV0dGVzdGVy?=, Dec 9, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    1,343
    =?Utf-8?B?ZG90bmV0dGVzdGVy?=
    Dec 15, 2005
  3. mh
    Replies:
    4
    Views:
    689
    Wolfgang Strobl
    May 31, 2005
  4. shailesh
    Replies:
    1
    Views:
    768
    Tim Golden
    Mar 28, 2007
  5. king
    Replies:
    1
    Views:
    270
Loading...

Share This Page