Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

Path

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shapper - 16 Feb 2008 20:05 GMT
Hello,

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

FileUploadInsert.SaveAs(Server.MapPath("App_Files/MyFile.jpg"))

or

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

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

Thanks,
Miguel
Anthony Jones - 16 Feb 2008 22:56 GMT
> Hello,
>
[quoted text clipped - 7 lines]
>
> 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.

Signature

Anthony Jones - MVP ASP/ASP.NET


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.