Created
November 2, 2017 06:43
-
-
Save kawakawa/e22a04d556b089d51868ae54fe346b30 to your computer and use it in GitHub Desktop.
C# FtpWebRequestでパスワード末に改行コードが含まれているとExceptionが発生する状況の再現
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//-----------------------------------------------------------------------------------// | |
//C# FtpWebRequestでパスワード末に改行コードが含まれているとExceptionが発生する状況の再現 | |
//-----------------------------------------------------------------------------------// | |
var ftpReq = (System.Net.FtpWebRequest)System.Net.WebRequest.Create(new Uri("ftp://" + ip + sendPath)); | |
//FTPユーザーとFTPパスワード | |
//ただし、FTPパスワードにワザと改行コードを付与する | |
ftpReq.Credentials = new System.Net.NetworkCredential(user,password+"\r\n"); | |
ftpReq.Method = System.Net.WebRequestMethods.Ftp.UploadFile; | |
ftpReq.KeepAlive = false; | |
ftpReq.UseBinary = false; | |
ftpReq.UsePassive = false; | |
//FileアップロードのStreamを取得 | |
//ここでException発生。 | |
//「状態の応答 (DataAlreadyOpen) は 'QUIT | |
//' コマンドへの応答に予期されていません。」 | |
var reqStrm = ftpReq.GetRequestStream(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment