Click here to Skip to main content
15,614,608 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;

}
Posted

1 solution

1) Are you sure there is no extra white space in the webRequest string?
2) check to make sure you have the correct privileges to write to that server.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900