I was using Server.MapPath to check if a file existed in the current domain and then display it so it would be displayed inwww.domainA.com/Pictures/PictureName.jpg
but now I want to check if the file exists on the same server, but in a different folder, which would be a different domain. I tried using an absolute url for the path but that didn't work. How would you do this?
Here's what I have now. Thanks
// Display the product's image if it has one
if (System.IO.File.Exists(Server.MapPath("Pictures/" + ProductLabel.Text +".jpg")) !=false){
ProductImage.ImageUrl = ("Pictures/" + ProductLabel.Text +".jpg");
}
this line of code will give u return true/false
based upon the directory exits on the server.
If Directory.Exists(NewPath)
Do you want to load an image which is not in your web site directory hierarchy?
Hi rkeslar,
Generally speaking, server.mappath is designed to return the physical path for those virtue paths which areUNDER your current domain.So-- if the virture path you want to check is outside your current domain( in another project), i'm afraid you cannot use it( Imagine how are you going to write the virtue path part??)
If you do want to check if a certain folder/file exist or not , simply using System.IO.File.Exists(physicalpath) will do it.But i'm assuming you have already known the physical path.
Hope my suggestion helps
0 comments:
Post a Comment