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()) {
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
source
share