Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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.

Reply With Quote
  #2 (permalink)  
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:03 PM.


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