User-926160538 posted
Hi I have following problem while get File Size from the FTP path after file upload in specific
FTP connection not all .
Exception Message : "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)."
Inner Exception is : FtpWebRequest error: 550 Size not allowed in ASCII mode.
I have used following code to fetch FTP File size.
if (objFtpState.StatusDescription.Contains("Transfer complete"))
{
req = (FtpWebRequest)FtpWebRequest.Create(txtUrl.Text + FileName);
req.Credentials = new NetworkCredential(txtUser.Text, txtFTPPassword.Text);
req.Method = WebRequestMethods.Ftp.GetFileSize();
try
{
wresponse = (FtpWebResponse)req.GetResponse();
}
catch (WebException ex)
{
FtpWebResponse response = (FtpWebResponse)ex.Response;
if (response.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable)
{
lblMsg.Text = "File not found in the FTP folder. Please contact administrator";
lblMsg.ForeColor = Color.Red;
}
}
}
After changing piece of code from req.Method = WebRequestMethods.Ftp.GetFileSize();
to req.UseBinary = true; req.Method = WebRequestMethods.Ftp.DownloadFile; working without exception.
1.What configuration required in FTP connection to work existing code. ?
2.How it's working when download file ?
Please give me your valuable solution.