Path

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    #1

    Path

    Hello,

    I am uploading a file. Which one should I use?

    FileUploadInser t.SaveAs(Server .MapPath("App_F iles/MyFile.jpg"))

    or

    FileUploadInser t.SaveAs(Server .MapPath("~/App_Files/MyFile.jpg"))

    Both work. Is "~/" necessary in this case?

    Thanks,
    Miguel
  • Anthony Jones

    #2
    Re: Path

    "shapper" <mdmoura@gmail. comwrote in message
    news:16de22fc-3623-4e77-9c97-91e0971c471c@28 g2000hsw.google groups.com...
    Hello,
    >
    I am uploading a file. Which one should I use?
    >
    FileUploadInser t.SaveAs(Server .MapPath("App_F iles/MyFile.jpg"))
    >
    or
    >
    FileUploadInser t.SaveAs(Server .MapPath("~/App_Files/MyFile.jpg"))
    >
    Both work. Is "~/" necessary in this case?
    Both work because the App_Files folder is found in the applications top
    folder and so is this page. If you move this page to a deeper folder but
    want the App_Files to remain at in the top folder then the former relative
    path will break. OTH, if you were to move both this page ant the App_Files
    folder into a deeper folder then the latter absolute path will break

    IOW, which one you use depends on how tightly coupled the location of the
    page executing the code is to the location of the App_Files folder. If
    App_Files is highly unlike to be moved deeper into the folder structure at
    somepoint in the future use the latter absolute path.


    --
    Anthony Jones - MVP ASP/ASP.NET


    Comment

    Working...