-1

FTPサーバーにファイルをアップロードしようとすると、「ログインしていないリモートサーバー530に接続できないwebexception」が表示され続けます

誰でもこの問題を解決する方法を知っていますか? ファイアウォールを無効にしようとしましたが、効果がありません

 /* Create an FTP Request */
                FtpWebRequest ftpRequest = (FtpWebRequest)FtpWebRequest.Create(ftpurl + "/" + remoteFile);
                /* Log in to the FTP Server with the User Name and Password Provided */
                ftpRequest.Credentials = new NetworkCredential(ftpuser, ftppassword,ftpurl);
                /* When in doubt, use these options */
                ftpRequest.UseBinary = true;
                ftpRequest.UsePassive = true;
                ftpRequest.KeepAlive = true;
                /* Specify the Type of FTP Request */
                ftpRequest.Method = WebRequestMethods.Ftp.UploadFile;
                /* Establish Return Communication with the FTP Server */
              Stream  ftpStream = ftpRequest.GetRequestStream();
                /* Open a File Stream to Read the File for Upload */
                FileStream localFileStream = new FileStream(localFile, FileMode.Create);
                /* Buffer for the Downloaded Data */
                byte[] byteBuffer = new byte[bufferSize];
                int bytesSent = localFileStream.Read(byteBuffer, 0, bufferSize);
                /* Upload the File by Sending the Buffered Data Until the Transfer is Complete */

                {
                    while (bytesSent != 0)
                    {
                        ftpStream.Write(byteBuffer, 0, bytesSent);
                        bytesSent = localFileStream.Read(byteBuffer, 0, bufferSize);
                    }
                }

                /* Resource Cleanup */
                localFileStream.Close();
                ftpStream.Close();
                ftpRequest = null;
4

1 に答える 1

0

あなたNetworkCredentialは間違っているようです。3 番目のパラメーターはドメインを設定します (参照: NetworkCredential コンストラクター)。に変更してみてください:

ftpRequest.Credentials = new NetworkCredential(ftpuser, ftppassword);
于 2013-06-12T09:55:37.060 に答える