Re: check if image or file exists

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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


"=?Utf-8?B?SGFyb2xkcw==?=" <Harolds@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:<6B638233-5CFB-448C-A7CC-019D5469828F@xxxxxxxxxxxxx>...
> 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
.



Relevant Pages

  • Re: Problems editing System Registry entries created by another application
    ... I followed the sample code to setup RegistryPermissions and followed sample ... In the end I get another exception that states that the key in the key/vlaue ...
    (microsoft.public.dotnet.security)
  • Re: SQL Stored procedure
    ... have tried the sample code given by Maligui yet? ... Public ReadOnly Property IsAlive As Boolean ... Dim instance As Thread ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Try/Catch
    ... Find my other post about the InnerException and sample code. ... It seems to work Ok without .tostring, and the exception is now ... aa is a UnauthorizedAccessException ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: inheritance question
    ... With the sample code below i get the error that i dont have enough ... arguments for the constructor i dont understand why i am getting that ... ie the "path" which was followed to reach the exception. ...
    (comp.lang.ruby)
  • MSWord Addin "Operation Abort"
    ... Below is the sample code for Word Add-in. ... This throws an exception on executing ... public void OnDisconnection(ext_DisconnectMode RemoveMode, ref ...
    (microsoft.public.office.misc)