locked
Accessing other files folder outside Website folder RRS feed

  • Question

  • User-1949910660 posted

     I have a question regarding copy file to a folder … here is the structure of the server ..



    All web pages (.aspx) are located on server D:\development\website1\webpages\default.aspx … (URL : http://servername/website1/webpages/default.aspx) … in default.aspx … I need to copy file to D:\FilesFolder\ … right now, it’s being hard-coded in code as :



    string FilesLocation  = "D:\\FilesFolder\\";



    Should we use Server.MapPath or Request.ServerVariables instead of “D:\\FilesFolder\\” ?? D:\\FilesFolder\\ is not a website .. just a folder outside the websites folder (development).

    Please advice.

    Tuesday, June 24, 2008 11:31 AM

Answers

  • User537870505 posted
    Yes, folders outside the web app folder are accessible by their physical path directly, provided the current user name has appropriate rights for the same.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 25, 2008 5:05 AM

All replies

  • User537870505 posted
    Server.MapPath only works with virtual folders. How about making an entry in web.config (appSettings) for the folder location and use it at runtime?
    Tuesday, June 24, 2008 11:43 AM
  • User-1949910660 posted

    so what you mean is we still call it directly from the drive (D:\) ... not http:\\servername\FileFolder ..? is there the only way?

    Tuesday, June 24, 2008 12:48 PM
  • User537870505 posted
    Yes, folders outside the web app folder are accessible by their physical path directly, provided the current user name has appropriate rights for the same.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 25, 2008 5:05 AM
  • User1220673890 posted

     What about displaying files outside of the web app?  Like PDF files that would show up as a link and be able to be viewed from the website?  Could that be done?

     Thanks.

    Thursday, August 28, 2008 4:27 PM
  • User-518589391 posted

    I have a problem opening a csv file outside of virtual directory or the web application folder. i want to open the csv file using a hyperlink. I have given asp.net user full rights.

    Something what CLprogrammer asked above.....

    Tuesday, September 2, 2008 11:16 AM
  • User-1853252149 posted

    What about displaying files outside of the web app?  Like PDF files that would show up as a link and be able to be viewed from the website?  Could that be done?

    That's just a link.  Nothing special to make that happen.

    Jeff

    Tuesday, September 2, 2008 11:38 AM
  • User-1853252149 posted

    I have given asp.net user full rights.

    Are you sure this is the user being denied access?

    I have a problem opening a csv file outside of virtual directory or the web application folder.

    Can you open one inside the web folder hierarchy?

    Jeff

    Tuesday, September 2, 2008 11:45 AM
  • User837668499 posted

    Yes, folders outside the web app folder are accessible by their physical path directly,

    Wednesday, September 3, 2008 4:19 AM
  • User-1371607825 posted

    You can access like this.

    webRootPath = Server.MapPath("~") docPath = Path.GetFullPath(Path.Combine(rootPath, "..\Documents/MyDocument.xml"))
    Saturday, October 26, 2013 8:09 AM