Okay so after a fair few hours I stumbled across Pete Mourfield article on code project and I was able to get the result required therefore I’m going to post this solution in case anyone else has the same problem.
Public Function CheckIfFtpFileExists(ByVal fileUri As String) As Boolean
Dim request As FtpWebRequest = WebRequest.Create(fileUri)
request.Credentials = New NetworkCredential("Username", "Password")
request.Method = WebRequestMethods.Ftp.GetFileSize
Try
Dim response As FtpWebResponse = request.GetResponse()
Catch ex As WebException
Dim response As FtpWebResponse = ex.Response
If FtpStatusCode.ActionNotTakenFileUnavailable = response.StatusCode Then
Return False
End If
End Try
Return True
End Function
To call the function
Dim CueDir As String = "C:\Users\DaBeast\Documents\Numark CUE\Playlists"
For Each fileNameA As String In Directory.GetFiles(CueDir, "*.m3u", SearchOption.AllDirectories)
Dim JustTheFileName As String = IO.Path.GetFileName(fileNameA)
If fileNameA.Contains("(") Then
GoTo GoToNextFile
Else
If CheckIfFtpFileExists("ftp://severaddress.com:333/PR/Playlists/" & JustTheFileName) Then
MsgBox(JustTheFileName & " This file is on the server")
Else
MsgBox(JustTheFileName & "This file is not on the server")
Dim fi As New FileInfo(fileNameA)
client.Upload(fi)
txtLog.AppendText(JustTheFileName & " uploaded")
End If
End If
GoToNextFile:
Next