Or even have a look at WebClient.

It is sufficient for what you are trying to do and relies on the default
proxy configuration (which saves your from having your own proxy handling)




cheers,
dominick

-----------------------------
Dominick Baier, DevelopMentor
http://www.leastprivilege.com


-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Ryan Heath
Sent: Mittwoch, 6. September 2006 11:51
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] determine if a tiff file exists on a url
location

File.Exists checks your hd whether the file is there or not.
Testing whether a file exists on the internet is something completely
different.

You might do something with WebRequest, to see if the server is
responding...

static bool Exists(string url)
{
try
{
  WebRequest wb = WebRequest.Create(url);
  using ( WebResponse rp = wb.GetResponse())
  {
   HttpWebResponse hrp = rp as HttpWebResponse;
   if ( hrp != null)
   {
    return hrp.StatusCode == HttpStatusCode.OK;
   }
   else
   {
    return false;
   }
  }
}
catch( WebException)
{
  return false;
}
}

I made a few assumptions here, but it should get you started, then again
getting a file from the internet is really something else as getting it from
your hd...

HTH
// Ryan

On 9/6/06, Lior Levy <[EMAIL PROTECTED]> wrote:
> Hello,
>
>
>
> I want to determine if a tiff file exists on a url location.
>
>
>
> The File Class is no good because the path can't be a url.
>
> only "c:\\MyDir\\MyFile.txt" or "\\\\MyServer\\MyShare"
>
>
>
> path = "http://www.serverName.com/folder/aaa.tiff";;
>
> lbl_ans.Text = File.Exists(path).ToString();
>
>
>
> Any idea?
>
> Thanks,
>
> Lior
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentorR  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to