PDA

Click to See Complete Forum and Search --> : IO.File.Exists?


Dmyze
Mar 4th, 2003, 12:49 PM
I have a directory set up that people can put images of themselves in. My program checks to see if they have put a default photo in, and if they have not it displays a generic image. No matter what I put into the IO.Fle.Exists Line It always returns false. I have made the folder in question a Public Shared folder with everyone having read access, and the ASP Account has full access to it.


If IO.File.Exists("\\server\Photos\Emp\" & oDis.Manager.ExchangeName & "\" & "default.jpg") Then
imgPic.ImageUrl = "http://server/Photos/Emp/" & oDis.Manager.ExchangeName & "/default.jpg"
Else
imgPic.ImageUrl = "http://server/Photos/Emp/NA/default.jpg"
End If

Cander
Mar 4th, 2003, 12:59 PM
might be because oDis.Manager.ExchangeName isnt returning what you think it is, or it is returning nothing. Debug that.

Dmyze
Mar 4th, 2003, 01:05 PM
I've walked though the routine, the command is correct.

Dmyze
Mar 4th, 2003, 01:52 PM
Suddenly an apple strikes me on the head.

I just realized that the Photos and the web site are on the same server so I just changed the command to:



If IO.File.Exists("D:\wwwroot\Photos\Emp\" & oDis.Manager.ExchangeName & "\" & "default.jpg") Then
imgPic.ImageUrl = "http://server/Photos/Emp/" & oDis.Manager.ExchangeName & "/default.jpg"
Else
imgPic.ImageUrl = "http://server/Photos/Emp/NA/default.jpg"
End If




Thanks for your help!

hellswraith
Mar 4th, 2003, 09:35 PM
You can probably use something like Server.MapPath

I haven't used it myself yet, so I can't give you the exact syntax, but it will free you from hard coding paths.

Dmyze
Mar 5th, 2003, 11:19 AM
I did try using Server.MapPath but was unsuccessful

PT Exorcist
Mar 5th, 2003, 02:54 PM
Server.MapPath("myPicture.jpg") will return C:\inetpub\wwwroot\myPicture.jpg for example (if wwwroot is the folder)