use*_*016 5 .net c# csv ftp c#-3.0
我能够通过身份验证,但我不知道如何读取CSV文件.通常从硬盘驱动器链接我这样读.
string[] allLines = System.IO.File.ReadAllLines(@"D:\CSV\data.csv");
Run Code Online (Sandbox Code Playgroud)
但是我如何从ftp中读取.我的Ftp路径就像ftp://ftp.atozfdc.com.au/data.csv 这是我通过ftp身份验证的代码.
String ftpserver = "ftp://ftp.atozfdc.com.au/data.csv";
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpserver));
reqFTP.UsePassive = false;
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential("username", "password");
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
reqFTP.Proxy = GlobalProxySelection.GetEmptyWebProxy();
FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
Run Code Online (Sandbox Code Playgroud)
FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
//use the response like below
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
string[] allLines = reader.ReadToEnd().Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9276 次 |
| 最近记录: |