|
-
Sep 16th, 2000, 05:56 PM
#1
Does anyone know if you can find out if a file exists at a URL? Let's say I am looking for a picture. It is at http://www.somewhere.com/pics/mypicture.jpg
Is there a way to use the inet control to verify that that file is there?
That way when I try to bring that file into my program using a byte array, I don't get an error or have to wait for the control to time out.
I want to steer clear of Winsock, my program is already written around inet control.
Just a little more to help, I need to go from the lower folder on a site, let's say, http://www.somewhere.com/somefolder/anotherfolder/ and look for the picture there, if it isn't there, go to the next folder up like http://www.somewhere.com/somefolder/
I just want to add this into my program so no matter where the picture goes in the site, I can get it and use it with my program. The picture changes, that is why it can't be included with the program.
-
Sep 16th, 2000, 09:37 PM
#2
Here is how to tell if a site exists using the MSInet Control.
Code:
Private Sub Command1_Click()
Text1.Text = Inet1.OpenURL("http://www.site.com/site.htm")
DoEvents
If InStr(Text1.Text, "404 Not Found") Then
MsgBox "Site does not exist!"
Else
MsgBox "Site exists!"
End If
End Sub
And to check folders, you'd have to use FTP.
Here is a good example of an FTP using Inet: InetFTP
-
Sep 16th, 2000, 10:05 PM
#3
Thanks Matt, I didn't even think about the 404 error. I will try to get that to work.
-
Sep 17th, 2000, 09:32 AM
#4
Frenzied Member
Code:
'The code from Matthew will not allways work ("404 Not Found" vs "404 not found" vs "404 NOT FOUND")
'rather use
If InStr(lcase(Text1.Text), "404 not found") Then
'or
If InStr(Text1.Text, "404 Not Found", VbTextCompare) Then
'do a check also for "file not found"
And maybe you can use
If text1 Like("*404*not found*") Then
'But I'm not sure about that.
[Edited by Jop on 09-17-2000 at 10:35 AM]
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|