I was trying to upload file using ftp.(To a Linux machine). The following is the code, which I have tried.
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;
FileStream stream = File.OpenRead(filename);
byte buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
Stream reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
catch (Exception ex)
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?
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)