Hi frds,
I m using the below code and getting error "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)". Please tell me how to resolve this problem.
private void Upload(string filename)
{
FileInfo fil = new FileInfo(filename);
FtpWebRequest requestFTPUploader = (FtpWebRequest)WebRequest.Create(FtpServerName+"/"+FtpFilePath+"/" + fil.Name);
requestFTPUploader.Credentials = new NetworkCredential(FtpUserId, FtpPassword);
requestFTPUploader.Method = WebRequestMethods.Ftp.UploadFile;
ServicePoint LServicePoint = requestFTPUploader.ServicePoint;
LServicePoint.ConnectionLimit = 1;
requestFTPUploader.Proxy = new WebProxy() { UseDefaultCredentials = true };
FileInfo fileInfo = new FileInfo(filename);
FileStream fileStream = fileInfo.OpenRead();
int bufferLength = 2048;
byte[] buffer = new byte[bufferLength];
Stream uploadStream = requestFTPUploader.GetRequestStream();
int contentLength = fileStream.Read(buffer, 0, bufferLength);
while (contentLength != 0)
{
uploadStream.Write(buffer, 0, contentLength);
contentLength = fileStream.Read(buffer, 0, bufferLength);
}
uploadStream.Close();
fileStream.Close();
requestFTPUploader = null;
}