On Oct 20, 7:18*pm, "David"
<david.colliver.N...@revilloc.REMOVETHIS.com> wrote:
> You would do a web request to try the file, and if it returns a 404 error,
> it is not there.
>
> It might also be worth checking other responses that 200, for example, a 301
> or a 302 is a redirect.
>
> --
> Best regards,
> Dave Colliver.http://www.AshfieldFOCUS.com
> ~~http://www.FOCUSPortals.com- Local franchises available
>
> "Carlos" <caher...@yahoo.com> wrote in message
>
> news:...
>
>
>
> > Hi again Alexey,
>
> > thanks for your prompt response. However, could you also please fill in
> > the blanks for those conditions. In other words, how would I check for the
> > existence in the URL path, and network. I know I just can use
> > system.io.file.exists for local resources.
>
> > Thanks again,
>
> > * Carlos.
>
> > "Alexey Smirnov" <alexey.smir...@gmail.com> wrote in message
> >news:577d5fb6-4c16-4033-8caa-....
> > On Oct 20, 4:46 pm, "Carlos" <caher...@yahoo.com> wrote:
> >> Hi all,
>
> >> I need to find out if a file exists given a local, or remote path. That
> >> is,
> >> if it resides the local machine, the network, or in a given URL . Is
> >> there
> >> any way to do that?
>
> >> Thanks in advance,
>
> >> Carlos.
>
> > if (s.StartsWith("http") || s.StartsWith("ftp"))
> > ... remote path
> > elseif ( s.StartsWith("\\") )
> > ... network path
> > else
> > ... local- Hide quoted text -
>
> - Show quoted text -
Carlos,
try like Dave suggested
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create
("http://....");
webRequest.AllowAutoRedirect = false;
try
{
HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
Response.Write(response.StatusCode.ToString()); // Returns "OK",
"Moved", "MovedPermanently", etc
}
catch (WebException ex)
{
Response.Write(ex.Message); // File does not exist
}
Hope this helps