Directoryinfo can not read network drive

Last post 06-03-2008 11:48 AM by aspfun. 4 replies.

Sort Posts:

  • Directoryinfo can not read network drive

    06-03-2008, 9:40 AM
    • Participant
      1,875 point Participant
    • aspfun
    • Member since 04-15-2004, 5:05 PM
    • Posts 769

    I code below to display files's info in a DataGrid from local drive, it works fine.

    ----------------------- 

    Dim dirInfo As New DirectoryInfo("c:\")dgFile.DataSource = dirInfo.GetFiles("*.doc")

    dgFile.RetrieveStructure()

    dgFile.DataBind()

    ----------------------------

    Once I change to network drive, (e.g. DirectoryInfo("R:\")), it will not work and return error message:

    "Could not find a part of the path 'R:\'."

    How to use it to display file's info from network drive?

     

     

  • Re: Directoryinfo can not read network drive

    06-03-2008, 9:53 AM
    • Contributor
      2,298 point Contributor
    • Raggers
    • Member since 02-17-2006, 4:40 PM
    • Germany
    • Posts 388

     You should URL sth like this (R is just a mapping drive to your network resource )

    \\fileServerName\Directory 

    If this solves your problem please mark as answer
  • Re: Directoryinfo can not read network drive

    06-03-2008, 10:08 AM
    • Participant
      1,875 point Participant
    • aspfun
    • Member since 04-15-2004, 5:05 PM
    • Posts 769

    Thank you for help.

    Once I changed to "\\order_server\order,  another error occured:

    Logon failure: unknown user name or bad password

    But, I can mapped \\order_server\order as R and open it without error.

     

  • Re: Directoryinfo can not read network drive

    06-03-2008, 11:10 AM
    • Contributor
      2,298 point Contributor
    • Raggers
    • Member since 02-17-2006, 4:40 PM
    • Germany
    • Posts 388

    I guess you should logon to the ActiveDirectory sth like

    System.DirectoryServices.DirectoryEntry d = new System.DirectoryServices.DirectoryEntry("", "", "", System.DirectoryServices.AuthenticationTypes.None); 

    http://www.codeproject.com/KB/system/everythingInAD.aspx 

    If this solves your problem please mark as answer
  • Re: Directoryinfo can not read network drive

    06-03-2008, 11:48 AM
    Answer
    • Participant
      1,875 point Participant
    • aspfun
    • Member since 04-15-2004, 5:05 PM
    • Posts 769

    I added

    <identity impersonate="true" />

    it works now

Page 1 of 1 (5 items)