check if image or file exists

F

Filip De Backer

Hi everyone,

I want to check if a certain file or image exists.
The picture exists when I use th eurl in my IE, but in my C# code, the if
statement returns false.
Is there another way to do this?

string PictureUrl =
"http://www.lessius-ho.be/webapp/personeelsindex/images/543.jpg";
if (File.Exists(PictureUrl))
{
imgFotoPersoon.ImageUrl = PictureUrl;
imgFotoPersoon.Visible = true;
}
else
{
imgFotoPersoon.Visible = false;
}

thanks in advance,

Filip De Backer
 
H

Harolds

Not tested but you could try something like this:

Dim objResponse As Net.HttpWebResponse
Dim objRequest As Net.HttpWebRequest = Net.WebRequest.Create(URL)
objRequest.Method = "GET"
objResponse = objRequest.GetResponse()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,900
Latest member
Nell636132

Latest Threads

Top