C#获取FTP文件详细备注信息
2013-09-09 14:52
453 查看
private void button1_Click(object sender, RoutedEventArgs e)
{
Uri uri = new Uri("ftp://192.168.1.14/");
FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(uri);
ftpRequest.Credentials = new NetworkCredential("zz", "123456");
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
FtpWebResponse response = (FtpWebResponse)ftpRequest.GetResponse();
StreamReader streamReader = new StreamReader(response.GetResponseStream(),System.Text.Encoding.UTF8);//
//List<string> directories = new List<string>();
List<string> directories1 = new List<string>();
string line = streamReader.ReadLine();
while (!string.IsNullOrEmpty(line))
{
directories.Add(line);
string str ;
str = line;
//C:\\Documents and Settings\\Administrator\\桌面\\1.jpg
//str.LastIndexOf(" ");//——得到最后一个“\\”的索引值
//str.Substring(0,str.LastIndexOf("\\")+1)——得到 C:\\Documents and Settings\\Administrator\\桌面\\
//str.Substring(str.LastIndexOf("\\")+1,str.LastIndexOf(".")-str.LastIndexOf("\\")-1);// ——得到 new1
//str.Substring(str.LastIndexOf(" "),str.Length-str.LastIndexOf(" "));// ——得到 x.jpg
directories1.Add(str.Substring(str.LastIndexOf(" "),str.Length-str.LastIndexOf(" ")));// ——得到 1.jpg
line = streamReader.ReadLine();//读下一串字符
}
treeView1.DataContext = directories1;
//treeView2.DataContext = directories1;
streamReader.Close();
}
{
Uri uri = new Uri("ftp://192.168.1.14/");
FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(uri);
ftpRequest.Credentials = new NetworkCredential("zz", "123456");
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
FtpWebResponse response = (FtpWebResponse)ftpRequest.GetResponse();
StreamReader streamReader = new StreamReader(response.GetResponseStream(),System.Text.Encoding.UTF8);//
//List<string> directories = new List<string>();
List<string> directories1 = new List<string>();
string line = streamReader.ReadLine();
while (!string.IsNullOrEmpty(line))
{
directories.Add(line);
string str ;
str = line;
//C:\\Documents and Settings\\Administrator\\桌面\\1.jpg
//str.LastIndexOf(" ");//——得到最后一个“\\”的索引值
//str.Substring(0,str.LastIndexOf("\\")+1)——得到 C:\\Documents and Settings\\Administrator\\桌面\\
//str.Substring(str.LastIndexOf("\\")+1,str.LastIndexOf(".")-str.LastIndexOf("\\")-1);// ——得到 new1
//str.Substring(str.LastIndexOf(" "),str.Length-str.LastIndexOf(" "));// ——得到 x.jpg
directories1.Add(str.Substring(str.LastIndexOf(" "),str.Length-str.LastIndexOf(" ")));// ——得到 1.jpg
line = streamReader.ReadLine();//读下一串字符
}
treeView1.DataContext = directories1;
//treeView2.DataContext = directories1;
streamReader.Close();
}
相关文章推荐
- C#通过shell32获取文件详细备注信息
- C#获取文件详细备注信息
- C#获取文件详细备注信息
- C#获取文件详细备注信息,MP3的Tag等等
- C# (asp.net) 获取文件详细备注信息
- C#获取文件详细备注信息
- C#获取文件详细备注信息
- 用C#和WMI获取逻辑驱动器详细信息(驱动器类型,文件系统,剩余空间等)
- 获取文件属性中详细信息里的各项目(vb 学习备注)
- C#获取指定文件著作权信息的方法
- FTP服务的LIST指令获取的文件列表信息的解析
- C#获取远程FTP文件列表
- C#获取ftp文件最后修改时间
- c#通过oledb获取excel文件表结构信息
- asp.net C#获取程序文件相关信息
- C# 获取wave文件信息【转】
- C#获取文件相关信息的方法
- C#获取远程FTP文件列表
- C# 获取文件大小,创建时间,文件信息,FileInfo类的属性表
- linux stat函数(获取文件详细信息)