本文介紹了嘗試 FTP 帶有特殊字符的文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
我有代碼:
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(url);
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.UseBinary = true; // Binary mode when downloading
request.Credentials = new NetworkCredential(user, password);
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
我總是收到錯誤:請求的 URI 對此 FTP 命令無效".
I always get the error: "The requested URI is invalid for this FTP command".
問題是 url 包含一個#".由于我無法阻止人們創建這種類型的文件,有沒有辦法可以轉義特殊字符并仍然處理文件?
The problem is the url contains a "#". Since I can't stop people from creating that type of file, is there a way I can escape special characters and still process the file?
推薦答案
用 "#" ->"%23" 替換字符串
URL 編碼不應包含哈希,因為:
Do a string replace with "#" ->"%23"
URL encodings shouldn't contain a hash because:
由于各種原因,某些字符可能會在 URL 中被誤解.這些字符也應始終進行編碼.
Some characters present the possibility of being misunderstood within URLs for various reasons. These characters should also always be encoded.
這篇關于嘗試 FTP 帶有特殊字符的文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!