远程服务器返回错误:(553)不允许文件名。 [英] The remote server returned an error: (553) File name not allowed.
问题描述
嗨
我试图使用ftp上传文件(到Linux机器)。以下是我尝试过的代码。
尝试
{
string filename = @ C:\ Users \Admin \ AppData \ Local \ Temp \Roaming.Doc跨度>;
字符串 ftpServerIP = ftp:// 192.168.1.246:21 /跨度>;
FileInfo fileInf = new FileInfo(filename);
FtpWebRequest request =(FtpWebRequest)FtpWebRequest.Create(ftpServerIP + / + fileInf。名称);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential( abc, 123 $);
request.UsePassive = true ;
request.UseBinary = true ;
request.KeepAlive = false ;
// 加载文件
FileStream stream = File.OpenRead(filename) ;
byte [] buffer = new byte [stream.Length];
stream.Read(buffer, 0 ,buffer.Length);
stream.Close();
Stream reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0 ,buffer.Length);
reqStream.Close();
}
catch (例外情况)
{
Console.WriteLine(ex.Message);
Console.ReadLine();
}
同样适用于Windows PC,但在具有以下功能的Linux PC中失败例外。
远程服务器返回错误:(553)不允许使用文件名。
任何人都可以帮我解决这个问题吗?
谢谢
塞巴斯蒂安
);
request.UsePassive = true ;
request.UseBinary = true ;
request.KeepAlive = false ;
// 加载文件
FileStream stream = File.OpenRead(filename);
byte [] buffer = new byte [stream.Length];
stream.Read(buffer, 0 ,buffer.Length);
stream.Close();
Stream reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0 ,buffer.Length);
reqStream.Close();
}
catch (例外情况)
{
Console.WriteLine(ex.Message);
Console.ReadLine();
}
同样适用于Windows PC,但在具有以下功能的Linux PC中失败例外。
远程服务器返回错误:(553)不允许使用文件名。
任何人都可以帮我解决这个问题吗?
谢谢
塞巴斯蒂安
< blockquote>塞巴斯蒂安,
我有同样的问题。希望以下链接可以帮助您或某人解决问题。
点击这里
Hi
I was trying to upload file using ftp.(To a Linux machine). The following is the code, which I have tried.
try
{
string filename = @"C:\Users\Admin\AppData\Local\Temp\Roaming.Doc";
String ftpServerIP = "ftp://192.168.1.246:21/";
FileInfo fileInf = new FileInfo(filename);
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(ftpServerIP + "/" + fileInf.Name);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("abc", "123$");
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false;
//Load the file
FileStream stream = File.OpenRead(filename);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.Close();
Stream reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadLine();
}
The same is working in a windows PC, but fails in a Linux PC with the following exception.
The remote server returned an error: (553) File name not allowed.
Can anyone please help me to solve this?
Thanks
Sebastian
"); request.UsePassive = true; request.UseBinary = true; request.KeepAlive = false; //Load the file FileStream stream = File.OpenRead(filename); byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, buffer.Length); stream.Close(); Stream reqStream = request.GetRequestStream(); reqStream.Write(buffer, 0, buffer.Length); reqStream.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadLine(); }
The same is working in a windows PC, but fails in a Linux PC with the following exception.
The remote server returned an error: (553) File name not allowed.
Can anyone please help me to solve this?
Thanks
Sebastian
Hi Sebastian,
I had the same issue. Hope the following link may help you or someone to overcome the problem.
Click here
这篇关于远程服务器返回错误:(553)不允许文件名。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!