I am trying to read a CSV file to upload it to a database Table using the following code:
FtpWebRequest reqFTP;
try
{
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpPath + fileName));
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
int count=0;
StringBuilder sb = new StringBuilder();
//GET THE FTP RESPONSE
using (System.Net.WebResponse tmpRes = reqFTP.GetResponse())
//^^^^^^^^^^^^^^ Error is on this line ^^^^^^^^^^^^^^
{
...
}
}
When the file name contains a space (which sometimes shows as %20 while debugging) i get the following error:
The remote server returned an error: (550) File unavailable (e.g., file not >found, no access).
If the filename does not contain a space or %20 it gets read fine.
The task involves to read the file parse contents save data in database and then move file in another folder.