Click here to Skip to main content
15,904,494 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm having a problem with ASP.NET

VB
Dim photoFile As String = Server.UrlEncode(PartInfo.PartNumber.Replace(" ", "_")) & ".jpg"
Dim photoPath As String = "~/partimages/" & photoFile
picbox.Width = New Unit(300)
picbox.Height = New Unit(200)
If IO.File.Exists(Server.MapPath(photoPath)) Then picbox.ImageUrl = photoPath
picbox.ImageUrl = photoPath
PartCat.Text = Server.MapPath(photoPath) & IO.File.Exists(Server.MapPath(photoPath))


When I browse to the webpage above, the "PartCat" textbox displays
E:\INTWeb\PartsImages\DE-X1105.jpgFalse

Which is the server filename, and IO.File.Exists returning false. However, the file does exist, with that path, on the server. If I click Start->Run and paste that in and click Ok, it opens the Photo Viewer.

So the server path is mapped correctly, so why does the .NET framework return false?

Any ideas?

Cheers

Edit: If I leave that "picbox.ImageUrl = photoPath" in without the If statement, the image displays
Posted
Updated 12-Jun-12 3:51am
v2
Comments
ZurdoDev 12-Jun-12 16:58pm    
Permissions. Make sure the account running the site has permissions.
MarqW 13-Jun-12 5:56am    
That threw me, because the image shows up if you just force it in the <asp:Image>, but you're correct. If you want to add it in the solutions section, I'll vote you.

Cheers
ZurdoDev 13-Jun-12 7:38am    
Good to hear.

1 solution

Permissions. Make sure the account running the site has permissions.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900