FtpWebrequest - filename contains german “Umlaute” like ä,ö

后端 未结 2 2064
被撕碎了的回忆
被撕碎了的回忆 2021-01-22 22:18

I\'m trying to get a file via FTP per FtpWebrequest - the download fails when the filename contains german Umlaute like ä,ö,ü.

Code:

FtpWebRequest reques         


        
相关标签:
2条回答
  • 2021-01-22 22:35

    Fetching the Filelist in UTF7 Encoding:

    StreamReader sr = new StreamReader(response.GetResponseStream(),Encoding.UTF7);
    

    did return the filename "Cases täglich .xls" in a way I can Downlod via Method "DownloadFile"

    0 讨论(0)
  • 2021-01-22 22:36

    It might have something to do with encodings. Some OSes support utf-8 encoded filenames, others don't; if you send a request using utf-8 encoding, and the server interprets it as something else, it won't find the files you request. If, OTOH, you just request a directory listing, all goes well because utf-8 is backward compatible with ascii-7 (that is, valid ascii-7 is also valid utf-8). My guess is you're sending utf-8 and interpret the result as something else, or vv.

    0 讨论(0)
提交回复
热议问题