检查FTP服务器上是否存在文件

时间:2018-08-28 09:43:13

标签: vb.net ftp

我在互联网上找到了此代码,但显然不起作用。我不知道问题出在我的FTP服务器...

表格

enter image description here

代码

Imports System.Net

Public Class Form1

    Dim ftpFile As String = "ftp://185.201.11.24/Team/ImersaStudios/Info.ini"
    Dim Username As String = "u171165696"
    Dim Password As String = "KU7KXW38"

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim request As FtpWebRequest = WebRequest.Create(ftpFile)
        request.Credentials = New NetworkCredential(Username, Password)
        request.Method = WebRequestMethods.Ftp.GetFileSize

        Dim response As FtpWebResponse

        Try
            response = request.GetResponse
            Label1.Text = "Found"

        Catch ex As WebException
            Label1.Text = "Not Found"
        End Try

    End Sub
End Class

0 个答案:

没有答案