C# ftprequest.response返回错误331(需要密码)

C# ftprequest.response返回错误331(需要密码),c#,.net,ftp,C#,.net,Ftp,我使用此代码连接到FTP帐户: ftpRequest = (FtpWebRequest)FtpWebRequest.Create(host + "/" + directory); /* Log in to the FTP Server with the User Name and Password Provided */ ftpRequest.Credentials = new NetworkCredential(user, pass);

我使用此代码连接到FTP帐户:

ftpRequest = (FtpWebRequest)FtpWebRequest.Create(host + "/" + directory);
            /* Log in to the FTP Server with the User Name and Password Provided */
            ftpRequest.Credentials = new NetworkCredential(user, pass);
            /* When in doubt, use these options */
            ftpRequest.Proxy = null;
            ftpRequest.UseBinary = true;
            ftpRequest.UsePassive = true;
            ftpRequest.KeepAlive = true;
            /* Specify the Type of FTP Request */
            ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
            /* Establish Return Communication with the FTP Server */
            ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
我使用相同的代码连接到4个帐户,除了一个帐户,其他一切都正常。对于此帐户,执行始终返回此异常: 远程服务器错误:(331)331用户名正确,需要密码。 奇怪的是,使用相同的凭据,我可以连接到FileZilla,因此我肯定会为这个帐户使用正确的密码和用户名。我想不出是什么导致了这个问题

提前感谢您提供的任何提示

根据建议,我在下面添加.net的网络日志和filezilla日志。网络日志是意大利语。我可以看到一个听起来像“请求的URI对此FTP命令无效”的错误

网络日志:

`System.Net Information: 0 : [7536] FtpWebRequest#31395883::.ctor(ftp://93.57.XX.XX/DIR_IN/)
System.Net Information: 0 : [7536] Tipo di installazione del sistema operativo corrente: 'Client'.
System.Net Information: 0 : [7536] FtpWebRequest#31395883::GetResponse(Metodo=NLST.)
System.Net Information: 0 : [7536] FtpControlStream#16919637 - Connessione creata da 192.168.1.5:1253 a 93.57.XX.XX:21.
System.Net Information: 0 : [7536] Associating FtpWebRequest#31395883 with FtpControlStream#16919637
System.Net Information: 0 : [7536] FtpControlStream#16919637 - Ricevuta risposta [220 Titan FTP Server 8.32.XXXX Ready.]
System.Net Information: 0 : [7536] FtpControlStream#16919637 - Invio comando [USER USERNAME] in corso...
System.Net Information: 0 : [7536] FtpControlStream#16919637 - Ricevuta risposta [331 User name okay, need password.]
System.Net Information: 0 : [7536] FtpWebRequest#31395883::(Rilascio connessione FTP n. 16919637.)
System.Net Error: 0 : [7536] Exception in FtpWebRequest#31395883::GetResponse - Errore del server remoto: (331) 331 User name okay, need password.
..
   in System.Net.FtpWebRequest.CheckError()
   in System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
   in System.IO.Stream.Close()
   in System.Net.ConnectionPool.Destroy(PooledStream pooledStream)
   in System.Net.ConnectionPool.PutConnection(PooledStream pooledStream, Object owningObject, Int32 creationTimeout, Boolean canReuse)
   in System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
   in System.Net.FtpWebRequest.GetResponse()
System.Net Information: 0 : [7536] FtpWebRequest#54861376::.ctor(ftp://93.57.XX.XX/)
System.Net Information: 0 : [7536] FtpWebRequest#54861376::GetResponse(Metodo=RETR.)
System.Net Information: 0 : [7536] RAS supportato: True
System.Net Information: 0 : [7536] FtpControlStream#34723915 - Connessione creata da 192.168.1.5:1254 a 93.57.XX.XX:21.
System.Net Information: 0 : [7536] Associating FtpWebRequest#54861376 with FtpControlStream#34723915
System.Net Information: 0 : [7536] FtpWebRequest#54861376::(Rilascio connessione FTP n. 34723915.)
System.Net Error: 0 : [7536] Exception in FtpWebRequest#54861376::GetResponse - URI richiesto non valido per questo comando FTP..
   in System.Net.FtpWebRequest.CheckError()
   in System.Net.FtpWebRequest.GetResponse()
` FILEZILLA日志:

2015-11-21 18:49:03 4968 3 Status: Connecting to 93.57.XX.XX:21...
2015-11-21 18:49:03 4968 3 Status: Connection established, waiting for welcome message...
2015-11-21 18:49:03 4968 3 Response: 220 Titan FTP Server 8.32.XXXX Ready.
2015-11-21 18:49:03 4968 3 Command: USER USERNAME
2015-11-21 18:49:03 4968 3 Response: 331 User name okay, need password.
2015-11-21 18:49:03 4968 3 Command: PASS ********
2015-11-21 18:49:03 4968 3 Response: 230-Welcome USERNAME from 151.20.XX.XX. You are now logged in to the server.
2015-11-21 18:49:03 4968 3 Response: 230 User logged in, proceed.
2015-11-21 18:49:03 4968 3 Command: SYST
2015-11-21 18:49:03 4968 3 Response: 215 UNIX Type: L8
2015-11-21 18:49:03 4968 3 Command: FEAT
2015-11-21 18:49:03 4968 3 Response: 211-Extensions Supported 
2015-11-21 18:49:03 4968 3 Response:  COMB
2015-11-21 18:49:03 4968 3 Response:  MLST type*;size*;modify*;create*;perm*;
2015-11-21 18:49:03 4968 3 Response:  SIZE
2015-11-21 18:49:03 4968 3 Response:  MDTM
2015-11-21 18:49:03 4968 3 Response:  MFMT
2015-11-21 18:49:03 4968 3 Response:  MFCT
2015-11-21 18:49:03 4968 3 Response:  EPRT
2015-11-21 18:49:03 4968 3 Response:  EPSV
2015-11-21 18:49:03 4968 3 Response:  XCRC
2015-11-21 18:49:03 4968 3 Response:  REST STREAM
2015-11-21 18:49:03 4968 3 Response:  AUTH SSL
2015-11-21 18:49:03 4968 3 Response:  AUTH TLS
2015-11-21 18:49:03 4968 3 Response:  CCC
2015-11-21 18:49:03 4968 3 Response:  PBSZ
2015-11-21 18:49:03 4968 3 Response:  PROT
2015-11-21 18:49:03 4968 3 Response:  DQTA
2015-11-21 18:49:03 4968 3 Response: 211 End
2015-11-21 18:49:03 4968 3 Status: Connected
2015-11-21 18:49:03 4968 3 Status: Retrieving directory listing...
2015-11-21 18:49:03 4968 3 Command: PWD
2015-11-21 18:49:03 4968 3 Response: 257 "/" is current directory.
2015-11-21 18:49:03 4968 3 Command: TYPE I
2015-11-21 18:49:03 4968 3 Response: 200 Type set to I.
2015-11-21 18:49:03 4968 3 Command: PASV
2015-11-21 18:49:03 4968 3 Response: 227 Entering Passive Mode (93,57,XX,XX,15,131).
2015-11-21 18:49:03 4968 3 Command: MLSD
2015-11-21 18:49:03 4968 3 Response: 150 File status okay; about to open data connection.
2015-11-21 18:49:03 4968 3 Response: 226 Closing data connection. Transferred 414 bytes.
2015-11-21 18:49:03 4968 3 Status: Directory listing successful

你能展示ftp url的样子吗?我想我可能知道原因,但需要看看你的路径是什么样子的。你能发布吗..例如,如果我使用的是类似以下内容的
string somestr=”ftp://192.168.1.2/somedir/somelog.dat";
通过放置
%2Fsomedir/..
更正问题应在您的案例中更正..启用并将日志附加到您的问题。来自FileZilla的相应日志文件(日志文件,而不是来自GUI的消息日志)也会有所帮助。您能显示ftp url的外观吗?我想我可能知道原因,但需要查看您的路径。您能发布它吗..例如,如果我使用的是类似以下内容的
string somestr=”ftp://192.168.1.2/somedir/somelog.dat";
通过放置
%2Fsomedir/..
更正问题应在您的案例中更正..启用并将日志附加到您的问题。来自FileZilla的相应日志文件(日志文件,而不是来自GUI的消息日志)也会有所帮助。