使用 FtpWebRequest 连接时出现错误 530 Not logged in
Getting a error 530 Not logged in when connecting using FtpWebRequest
能想到的我都试过了。我正在尝试从 FTP 服务器获取目录列表。我可以从 FileZilla 登录并 list/download。
我的密码如下所示(字母已更改):
c0dlWTRBOZc=
我试过使用 Normalize()
而没有使用它。
它在 GetResponse()
行出错。
代码如下:
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(thisConnection.remoteFTP_URI);
request.KeepAlive = true;
request.UsePassive = true;
request.UseBinary = true;
request.Method = WebRequestMethods.Ftp.ListDirectory;
request.Credentials = new NetworkCredential(thisConnection.userName.Normalize(),thisConnection.passWord.Normalize());
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
我在其他 FTP 服务器上使用完全相同的代码,没有任何问题。我无法直接控制服务器,因此更改密码或其他服务器设置会有问题。
感谢您的帮助!
您的密码字符串看起来像 base64 编码的。
FileZilla 在其配置文件 (sitemanager.xml
) 中实际使用的格式是什么。
所以我的猜测是您从 sitemanager.xml
复制了编码密码,并尝试将其用作 FtpWebRequest
.
中的文字密码
确保使用实际的文字密码。如果不记得,用一些base64解码器。
你会 find plenty of them online.
能想到的我都试过了。我正在尝试从 FTP 服务器获取目录列表。我可以从 FileZilla 登录并 list/download。
我的密码如下所示(字母已更改):
c0dlWTRBOZc=
我试过使用 Normalize()
而没有使用它。
它在 GetResponse()
行出错。
代码如下:
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(thisConnection.remoteFTP_URI);
request.KeepAlive = true;
request.UsePassive = true;
request.UseBinary = true;
request.Method = WebRequestMethods.Ftp.ListDirectory;
request.Credentials = new NetworkCredential(thisConnection.userName.Normalize(),thisConnection.passWord.Normalize());
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
我在其他 FTP 服务器上使用完全相同的代码,没有任何问题。我无法直接控制服务器,因此更改密码或其他服务器设置会有问题。
感谢您的帮助!
您的密码字符串看起来像 base64 编码的。
FileZilla 在其配置文件 (sitemanager.xml
) 中实际使用的格式是什么。
所以我的猜测是您从 sitemanager.xml
复制了编码密码,并尝试将其用作 FtpWebRequest
.
确保使用实际的文字密码。如果不记得,用一些base64解码器。
你会 find plenty of them online.