I am trying to read a CSV file from ftp server using c# but problem is it does not allow me to read and throwing this error
The remote server returned an error: (530) Not logged in.
I have spent lot of time on researching this issue unfortunately i could not find the solution yet.Any help would be highly appriciatedhere is the code\[code\] StringBuilder result = new StringBuilder(); FtpWebRequest reqFTP; try { String ftpserver = "ftp://domain.com/StatusChanges_20120922_043057.csv"; reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpserver)); reqFTP.UsePassive = false; reqFTP.UseBinary = true; reqFTP.Credentials = new NetworkCredential("[email protected]", "password"); reqFTP.Method = WebRequestMethods.Ftp.DownloadFile; reqFTP.Proxy = GlobalProxySelection.GetEmptyWebProxy(); FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8); string line = ""; while (reader.Peek() > -1) { line = reader.ReadLine(); Console.WriteLine(line);//**********HTML was wrote out here************* } if (result.ToString().LastIndexOf('\n') >= 0) result.Remove(result.ToString().LastIndexOf('\n'), 1); reader.Close(); response.Close(); return result.ToString(); } catch (Exception ex) { }\[/code\]
The remote server returned an error: (530) Not logged in.
I have spent lot of time on researching this issue unfortunately i could not find the solution yet.Any help would be highly appriciatedhere is the code\[code\] StringBuilder result = new StringBuilder(); FtpWebRequest reqFTP; try { String ftpserver = "ftp://domain.com/StatusChanges_20120922_043057.csv"; reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpserver)); reqFTP.UsePassive = false; reqFTP.UseBinary = true; reqFTP.Credentials = new NetworkCredential("[email protected]", "password"); reqFTP.Method = WebRequestMethods.Ftp.DownloadFile; reqFTP.Proxy = GlobalProxySelection.GetEmptyWebProxy(); FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8); string line = ""; while (reader.Peek() > -1) { line = reader.ReadLine(); Console.WriteLine(line);//**********HTML was wrote out here************* } if (result.ToString().LastIndexOf('\n') >= 0) result.Remove(result.ToString().LastIndexOf('\n'), 1); reader.Close(); response.Close(); return result.ToString(); } catch (Exception ex) { }\[/code\]