[Internet] Verifin Existance of a file

Posted on 2005-04-17
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?
Question by:bennetjosem
    LVL 1

    Expert Comment

    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.
    LVL 6

    Expert Comment

    Private Sub Command1_Click()
          Const strWebURL = ""
          Dim strHTML As String

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

    End Sub
    LVL 9

    Expert Comment

    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        
            _request = System.Net.WebRequest.Create(MyUrl)            
            _response = _request.GetResponse()            
            Return "Good Link"

        Catch ex As Exception
            Return "Bad Link"        

        End Try
    End Function
    Link Status: <# "CheckURL("") %>

    Let me know...
    LVL 35

    Accepted Solution


    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("")

    MsgBox blnTest_URL("")

    MsgBox blnTest_URL("")


    LVL 48

    Assisted Solution

    by:Ryan Chong
    Have a look on this previous discussion at:

    How to check if file exists on a web server

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now