C# WinForm 如何FTP上某文件夹下的文件目录? 本帖最后由 dingxinghui 于 2010-07-26 21:19:06 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://topic.csdn.net/u/20081027/23/1121933a-8fd1-490c-bec2-8cf3e3a3176d.html 访问远程的ftp应该需要身份验证的。可以用“映射网络驱动器”实现,不知道是不是想要的结果。 private string[] GetFileList(string path, string WRMethods)//上面的代码示例了如何从ftp服务器上获得文件列表 { string[] downloadFiles; StringBuilder result = new StringBuilder(); try { Connect(path); reqFTP.Method = WRMethods; WebResponse response = reqFTP.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);//中文文件名 string line = reader.ReadLine(); while (line != null) { result.Append(line); result.Append("\n"); line = reader.ReadLine(); } // to remove the trailing '\n' result.Remove(result.ToString().LastIndexOf('\n'), 1); reader.Close(); response.Close(); return result.ToString().Split('\n'); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); downloadFiles = null; return downloadFiles; } } public string[] GetFileList(string path)//上面的代码示例了如何从ftp服务器上获得文件列表 { return GetFileList("ftp://" + ftpServerIP + "/" + path, WebRequestMethods.Ftp.ListDirectory); } public string[] GetFileList()//上面的代码示例了如何从ftp服务器上获得文件列表 { return GetFileList("ftp://" + ftpServerIP + "/", WebRequestMethods.Ftp.ListDirectory); } sortlist的超难度问题 求个正则表达式 如何在新增一个 class 时, 让它默认 using 一个命名空间? C#中如何判断鼠标和键盘同时按下? 问一个抽象类的问题 能不能用C#创建数据库中的视图??9999999999999 怪!!!!!!!!!! C#中调取数据问题 一个关于进度条的例题,不知哪里有问题?? 如何在一个类(A)中控制 Winfrom界面(B)中的listBox(A是一个独立的类,不继承自B)?请指教! C# Graphics 有关 transform 的问题 C#中数据库连接问题
private string[] GetFileList(string path, string WRMethods)//上面的代码示例了如何从ftp服务器上获得文件列表
{
string[] downloadFiles;
StringBuilder result = new StringBuilder();
try
{
Connect(path);
reqFTP.Method = WRMethods;
WebResponse response = reqFTP.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);//中文文件名
string line = reader.ReadLine();
while (line != null)
{
result.Append(line);
result.Append("\n");
line = reader.ReadLine();
}
// to remove the trailing '\n'
result.Remove(result.ToString().LastIndexOf('\n'), 1);
reader.Close();
response.Close();
return result.ToString().Split('\n');
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
downloadFiles = null;
return downloadFiles;
}
}
public string[] GetFileList(string path)//上面的代码示例了如何从ftp服务器上获得文件列表
{
return GetFileList("ftp://" + ftpServerIP + "/" + path, WebRequestMethods.Ftp.ListDirectory);
}
public string[] GetFileList()//上面的代码示例了如何从ftp服务器上获得文件列表
{
return GetFileList("ftp://" + ftpServerIP + "/", WebRequestMethods.Ftp.ListDirectory);
}