I am using the code below to change the location of a Secondary data connection. This works fine but if the file does not exist, the FileQueryConnection.Execute() method generates an error of its own regardless of the Try block. I would like to avoid this error (confuses the users) by checking for the existence of the file before changing the FileQueryConnection object.
Locating a local file would be easy but I have not been able to find a method of checking for the file on our SharePoint server using visual basic.
If someone could point me in the right direction, I would be grateful.
Dim myConnection As FileQueryConnection = Me.DataConnections("Project Charter")
myConnection.FileLocation = strPath + "Project Charters/" & xnProjectName.Value.Trim & " Project Charter.xml"
Try
myConnection.Execute()
Catch ex As Exception
MessageBox.Show("File does not exist", "Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try