FtpWebrequest - filename contains the German "Umlaute", such as ä, ö

I try to receive a file via FTP for FtpWebrequest - the download is not performed when the file name contains German Umlaute, for example, ä, ö, ü.

the code:

FtpWebRequest request2 = (FtpWebRequest)WebRequest.Create("ftp://re-web-03.servername.de/" + "filename with ä.xls");
request2.Method = WebRequestMethods.Ftp.DownloadFile;
request2.Credentials = new NetworkCredential("xxx", "xxx");
using (FtpWebResponse response = (FtpWebResponse)request2.GetResponse()) { // <-- Exception: The remote server returned an error: (550) File unavailable ...

When changing the file name to "filename with ae.xls" it works.

Exception: WebException: the remote server returned an error: (550) File not available (for example, file not found, no access).

The list of directories via ftp works fine and shows the file name:

FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://re-web-03.servername.de/");
request.Method = WebRequestMethods.Ftp.ListDirectory;
request.Credentials = new NetworkCredential("xxx", "xxx");
using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
{
    StreamReader sr = new StreamReader(response.GetResponseStream());
    while (!sr.EndOfStream)
    {   Console.WriteLine(sr.ReadLine()); } // --> output is "filename with ä.xls"
}

Output: "filename with ä.xls".

Does anyone have any advice on how to deal with this problem - I have no influence on naming these files ...

Thanks so much in advance Tobi

+2
source share
2 answers

- . utf-8 , - ; utf-8, - , , . , OTOH, , , utf-8 ascii-7 ( ascii-7 utf-8). , utf-8 vv.

+2

UTF7:

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

" täglich.xls" , Downlod "DownloadFile"

+1

All Articles