Results 1 to 7 of 7

Thread: Another question about Winsock and File search

  1. #1

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Question Another question about Winsock and File search

    For example, we have this website: "http://www.website.com/"
    Is any possibility to know the name of the subfolders of this site, for example:
    "http://www.website.com/data/"
    or
    "http://www.website.com/data/sql"


    Thank you

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Another question about Winsock and File search

    Only if the web server has directory listings turned on. If not, you will get a (403?) - Forbidden error.

    The only other way would be if you have FTP access to the server.

  3. #3

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Re: Another question about Winsock and File search

    An how can I make a directory listing from a website? Inet, WinSock? Or other?
    Suggestions needed.

    Thank you.

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Another question about Winsock and File search

    A website will list directories if it has that setting enabled. Otherwise, it won't and there is no way to get it to.

    Example of directory listings:
    http://www.dannydotguitar.com/images/

    Now if I were to go and turn them off (which I've been meaning to do) then you wouldn't see those directories listed, you would just see an error message.

  5. #5

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Re: Another question about Winsock and File search

    What I mean is: how can I do that programmatically, in vb6?

    Thank you

  6. #6
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Another question about Winsock and File search

    If you can put your vb6 application on the server and excute it there, then possibly (thought I don't know how) you can do it.

    But if you don't have access to the web-server, there is nothing you can do...

    That setting is on the server only...

  7. #7
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Another question about Winsock and File search

    I think he meant how to receive the directory listing from his VB program.

    If that's not what you mean then CVMichael is right.

    If you want your program to receive the directory listings then you can use something like this:

    Add a winsock control (Winsock1) to your form and paste this code in there:
    Code:
    Option Explicit
    
    'Received data buffer.
    Private strBuffer As String
    
    Private Sub Form_Load()
        With Winsock1
            .Close
            strBuffer = vbNullString
            .Connect "www.dannydotguitar.com", 80
        End With
        
        'The winsock control is now connecting.
        'If it connects successfully, the Connect() event will fire.
        'If there is an error, the Error() event will fire.
    End Sub
    
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        Winsock1.Close
        strBuffer = vbNullString
    End Sub
    
    'Connected to web server.
    Private Sub Winsock1_Connect()
        'We're connected, so send the GET request.
        'In this case, it's for the folder /images/.
        'If you request a folder and the server has directory
        'listings enabled, then it will return the directory listing.
        'Unless there is an index.html/index.php file in that folder.
        
        Dim strGET As String
        
        strGET = "GET /images/ HTTP/1.1" & vbCrLf
        strGET = strGET & "Host: www.dannydotguitar.com" & vbCrLf
        strGET = strGET & "User-Agent: VB" & vbCrLf
        strGET = strGET & "Accept: *.*" & vbCrLf
        strGET = strGET & "Connection: Close" & vbCrLf & vbCrLf
        
        Winsock1.SendData strGET
        
        'GET request is sending.
        'Next event to fire should be the DataArrival() event.
    End Sub
    
    'Receiving data.
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
        Winsock1.GetData strBuffer, vbString, bytesTotal
        
        Debug.Print strBuffer
    End Sub
    
    'Connection error.
    Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
        Winsock1.Close
        MsgBox Description, , "Error (#" & Number & ")"
    End Sub
    Note that, even with directory listings enabled on the web server, you still might not get a directory listing returned, because:

    a. The directory has an index file (index.html, index.php, etc.)
    b. The directory is password protected (htaccess)
    c. And a few other reasons that aren't coming to mind right now...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width