file exists for URL

robszar

Member
Joined
Mar 23, 2009
Messages
8
Programming Experience
Beginner
I want to check of a file exists but I can't use IO.fileexists because it's a URL, anyone have an alternative way to accomplish this?

if IO.FileExists("http://sharepointtest/Shared%20Documents/photo.jpg") then
userPic.ImageUrl = "http://sharepointtest/Shared%20Documents/photo.jpg"
end if
 
Use HttpWebRequest

Do This:

VB.NET:
Dim strURL As String
strURL = "http://sharepointtest/Shared%20Documents/photo.jpg"

Dim objStream As Stream
Dim objWebReq As HttpWebRequest
Dim objWebResp As HttpWebResponse

Try
            objWebReq = WebRequest.Create(strURL)
            objWebResp = objWebReq.GetResponse()
            objStream = objWebResp.GetResponseStream()
            userPic.ImageUrl = strURL
Catch ex As Exception
           // File not exists
            Return ex.Message
End Try
 
Back
Top