?
Solved

[Internet] Verifin Existance of a file

Posted on 2005-04-17
7
Medium Priority
?
212 Views
Last Modified: 2010-05-02
I just wanna create a programme which ask for a u rl from the user and i wanna verify weather that url directs to a file in the web. If its directs i wanna display a message. But i don want to download the file. Just want to verify the url.
How can i do that?
0
Comment
Question by:bennetjosem
5 Comments
 
LVL 1

Expert Comment

by:Netlink2
ID: 13802051
I don't know if you have an ftp server or not at the site, but if you do, you could try using an Internet Transfer Control using;

netFTP.RemoteHost = "hostname"
netFTP.Username = "Username"
netFTP.Password = "Password"
ftpGET.Execute , "DIR \directory\filename"
Make srue the protocol is set to icFTP in the properties.

That's one idea, anyway.
0
 
LVL 6

Expert Comment

by:osmodean
ID: 13802081
Private Sub Command1_Click()
      Const strWebURL = "http://www.anysite.com"
      Dim strHTML As String

      Inet1.AccessType = icDirect
      Inet1.RequestTimeout = 300 'Seconds = 5 Minutes
      Inet1.URL = WEB_URL
      strHTML = Inet1.OpenURL

End Sub
0
 
LVL 9

Expert Comment

by:stengelj
ID: 13802310
How's this work for you...

<script runat="server">
Function CheckURL(ByVal MyUrl As String) As String

    Dim _request As System.Net.HttpWebRequest        
    Dim _response As System.Net.HttpWebResponse        
   
    Try            
        _request = System.Net.WebRequest.Create(MyUrl)            
        _response = _request.GetResponse()            
        _response.Close()  
        Return "Good Link"

    Catch ex As Exception
        Return "Bad Link"        

    End Try
End Function
</script>
.......
Link Status: <# "CheckURL("http://mydomain.com/File.ext") %>



Let me know...
0
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 252 total points
ID: 13802356
Alternatively,

Option Explicit

Private Declare Function URLDownloadToFile _
                     Lib "urlmon.dll" _
                   Alias "URLDownloadToFileA" _
                  (ByVal pCaller As Long, _
                   ByVal strURL As String, _
                   ByVal stFileName As String, _
                   ByVal dwReserved As Long, _
                   ByVal lpfnCB As Long) As Long

Public Function blnTest_URL(ByVal strURL As String) As Boolean

  blnTest_URL = (URLDownloadToFile(0&, strURL, 0&, 0&, 0&) = 0&)
 
End Function



Usage example:

MsgBox blnTest_URL("http://google.co.uk/")
[True]

MsgBox blnTest_URL("http://google.co.uk/index.htm")
[False]

MsgBox blnTest_URL("http://google.co.uk/index.html")
[True]

BFN,

fp.
0
 
LVL 54

Assisted Solution

by:Ryan Chong
Ryan Chong earned 248 total points
ID: 13803857
Have a look on this previous discussion at:

How to check if file exists on a web server
http:Q_21241424.html
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question