Mit folgendem Code überprüfe ich, ob eine URL oder eine Datei online existiert. Das funktioniert auch problemlos für eine URL (Test1) und eine Datei (Test2). Nun möchte ich aber auch prüfen, ob ein Ordner existiert (Bsp.: "http://www.test.com/folder/subfolder/". Das funktioniert dem dem Code jedoch nicht. Wie kann ich abfragen, ob ein Ordner online existiert? Vielen Dank und Gruss, Henner
Private Declare Function DeleteUrlCacheEntry Lib "wininet.dll" Alias "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long
Public Function GetLinkStatus(ByVal strUrl As String) As Boolean
Dim objXMLHTTP As Object
If Not Left$(strUrl, 7) = "http://" Then strUrl = "http://" & strUrl
Set objXMLHTTP = CreateObject("Msxml2.XMLHTTP")
On Error Resume Next
objXMLHTTP.Open "GET", strUrl, False
objXMLHTTP.Send
GetLinkStatus = objXMLHTTP.Status = 200
Set objXMLHTTP = Nothing
On Error GoTo 0
End Function
Public Sub Test1()
DeleteUrlCacheEntry "http://www.test.com/"
If GetLinkStatus("http://www.test.com/") Then MsgBox "URL erreichbar"
End Sub
Public Sub Test2()
DeleteUrlCacheEntry "http://www.test.com/file.txt"
If GetLinkStatus("http://www.test.com/file.txt") Then MsgBox "URL erreichbar"
End Sub