locked
directory and files list on network shares RRS feed

  • Question

  • User1484644233 posted

    Hi Guys

     I need to show files list from a network shared folder. If you have sample snippet could you please post it here?

    I know how to show my local folder or localshare however I couldn't figure out the network folders yet.

     thanks.

    Friday, June 22, 2007 2:57 PM

Answers

  • User113421904 posted

    Hi patron,

    Here is an example:

     string unc = @"\\server\share";
     DirectoryInfo di = new DirectoryInfo(unc);
     FileInfo[] files = di.GetFiles("*.*");
     foreach(FileInfo fi in files)
     {
      //Do something      
     }

    But please make sure your ASP.NET web application has permissions on the shared folder.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 27, 2007 1:58 AM
  • User-1509636757 posted

    I found out that aspnet user account didn't hjave permission to that network drive. So, I have to find another solution.
     

    if ASPNET account is not having permission to that network drive.. than you can Impersonate your site.. with UserName and Password who is having full control/permission over that network drive...

    let me know if you have any doubts..

    hope this helps./. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 28, 2007 1:24 AM

All replies

  • User1442879938 posted

    Well to access the network folders you need to gie the network path. So you need to specify the complete network path.
    Say \\computername\sharename\.....

    Friday, June 22, 2007 4:14 PM
  • User1484644233 posted

    I tried that already. didn't work. tomorrow I will post my script .

     

    Saturday, June 23, 2007 8:25 AM
  • User113421904 posted

    Hi patron,

    Here is an example:

     string unc = @"\\server\share";
     DirectoryInfo di = new DirectoryInfo(unc);
     FileInfo[] files = di.GetFiles("*.*");
     foreach(FileInfo fi in files)
     {
      //Do something      
     }

    But please make sure your ASP.NET web application has permissions on the shared folder.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 27, 2007 1:58 AM
  • User-1509636757 posted

     specify full UNC path as described above as \\computername\sharename\.....

    and be sure that ASPNET account has full permission over that network share.

     

    Wednesday, June 27, 2007 4:21 AM
  • User1484644233 posted

    Thankyou all for your help, I found out that aspnet user account didn't hjave permission to that network drive. So, I have to find another solution.

     

    thanks you all for your efforts.

    Good day.

    Cemal

    Wednesday, June 27, 2007 2:15 PM
  • User-1509636757 posted

    I found out that aspnet user account didn't hjave permission to that network drive. So, I have to find another solution.
     

    if ASPNET account is not having permission to that network drive.. than you can Impersonate your site.. with UserName and Password who is having full control/permission over that network drive...

    let me know if you have any doubts..

    hope this helps./. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 28, 2007 1:24 AM