Home All Groups Group Topic Archive Search About
Author
22 Jun 2005 10:41 AM
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

Author
22 Jun 2005 3:52 PM
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()


Show quoteHide quote
"Filip De Backer" wrote:

> 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
Author
23 Jun 2005 12:33 PM
oraclevsmicrosoft
This sounds good, but if the URI is incorect this will throw an
exception. You should use a  "try catch" structure to return a
boolean.
Here is a sample code close to your problem :
http://oraclevsmicrosoft.blogspot.com/2005/06/web-crawlerregular-expressions-and.html
(look for the "loadUrl" method)

Hope this helps

Marc Boizeau

http://oraclevsmicrosoft.blogspot.com


Show quoteHide quote
"=?Utf-8?B?SGFyb2xkcw==?=" <Haro***@discussions.microsoft.com> wrote in message news:<6B638233-5CFB-448C-A7CC-019D5469828F@microsoft.com>...
> 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()
>
>
> "Filip De Backer" wrote:
>
> > 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