好的,我正在制作这个程序,它会自动从我的远程 ftp 服务器获取用户名和密码,然后登录。但它给了我一个错误,上面写着“对象引用未设置为对象的实例”
这是我的代码示例:
Imports System.Net
Imports System.Net.FtpClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Using ftp = New FtpClient()
Dim credentials As New NetworkCredential
ftp.Host = "my ftp server"
credentials = ftp.Credentials
Dim username As String
username = credentials.UserName.ToString 'Object reference not set to an instance of an object
Dim password As String
password = credentials.Password.ToString
End Using
End Sub