First, sorry for my rusty english !
Before launching a process, I have to test if files are existing in a Sharepoint library.
My Microsoft environment (Visual Studio 2022) advise this:
WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.
I would like to have a function to use it like this:
If SharepointFileExist(strMyFile) then
else
endif
I try to use sample code I find in stackoveflow, but I can’t succeed…
For exemple, this code doesn’t work:
Private Function SharepointFileExist(ByVal strHost As String) As Boolean
Try
Dim request As WebRequest = WebRequest.Create(strHost)
request.UseDefaultCredentials = True
request.PreAuthenticate = True
Dim response As WebResponse = request.GetResponse()
Call MsgBox("SUCCESS!!!")
Return True
Catch ex As Exception
Call MsgBox("ERROR: " & ex.ToString)
Return False
End Try
End Function
Can you give me the full content I need to achieve function SharepointFileExist() ?
Thank you in advance,
Golard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.