Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
| Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 5th, 2007, 05:43 PM
Authorized User
 
Join Date: Jul 2003
Location: , , .
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default Determining if a Remote File Exists

Hello Everyone and thanks for your help in advance. I am working on a project that displays images from a remote server. In the event an image does not exist, I need to display a default image in its place. My question is how do I determine if the file exists in the first place? The file.exists method does not work for this as I need to reference the photo in a format such as http://www.somesite.com/images/image.jpg. Any ideas on how to efficiently accomplish this would be greatly appreciated.

 
Old January 5th, 2007, 11:56 PM
Friend of Wrox
Points: 687, Level: 9
Points: 687, Level: 9 Points: 687, Level: 9 Points: 687, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: Chennai, Tamilnadu, India.
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello

AS OF MY KNOWLEDGE...

file.exist works for local file system, if you want to check the remote file, then use is this way

//Make reference to this
using System.Web;

//Check the content length.
string sMonitoringURI = "http://www.somesite.com/images/image.jpg";
WebRequest wrq = WebRequest.Create(sMonitoringURI);

//Begin: Only needed if you are connecting to internet via proxy
WebProxy wp;
wp = new WebProxy("192.168.0.1", 8080);
wrq.Proxy = wp;
//End:

WebResponse wrp;
wrp = wrq.GetResponse();
long l = wrp.ContentLength; //Over Here
wrp.Close();
wrq.Abort();

And rest as you know already.

I guess I have understood your problem, If not let me know will try to fix it in better way. Hope this helps.

With Regards,
Raghavendra Mudugal




Similar Threads
Thread Thread Starter Forum Replies Last Post
File Already exists Error srsandhu Classic ASP Basics 7 February 23rd, 2007 04:21 PM
File already exists srsandhu ASP.NET 1.0 and 1.1 Basics 1 February 14th, 2007 08:43 PM
Determining File Types seananderson Access VBA 2 February 12th, 2007 12:59 PM
hei,anyone know how to check a remote file exists lsj113 C# 2005 3 November 28th, 2006 02:55 AM
checking file exists on remote server pete_m Classic ASP Basics 11 August 2nd, 2004 02:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.