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();

}

C#获取FTP文件详细备注信息的更多相关文章

  1. C# 获取文件详细备注信息 (如图片、视频实际创建时间)

    在整理照片/视频时想根据实际拍摄时间重命名文件,但 System.IO.FileInfo 只能获取到文件的创建时间或最后写入时间,不符合要求,遂寻找解决方案 方案 1: System.Drawing ...

  2. C#通过shell32获取文件详细备注信息

    1.从系统Window/System32文件夹中Copy出 Shell32.dll Com组件 将Shell32.dll文件引用到项目中,并设置“嵌入互操作类型”为false http://blog. ...

  3. linux系统从pci.ids文件获取硬件设备详细厂商信息

    机器采样: [root@ht24 hwdata]# cat /etc/redhat-release ; uname -r CentOS Linux release 7.9.2009 (Core) 3. ...

  4. c#FTP操作类,包含上传,下载,删除,获取FTP文件列表文件夹等Hhelp类

    有些时间没发表文章了,之前用到过,这是我总结出来关于ftp相关操作一些方法,网上也有很多,但是没有那么全面,我的这些仅供参考和借鉴,希望能够帮助到大家,代码和相关引用我都复制粘贴出来了,希望大家喜欢 ...

  5. C++ 下使用curl 获取ftp文件

    从http://curl.haxx.se/下载的win32版本的curl都不能使,#include <curl.h>后总是报错:external symbol ,意思就是没有链接到curl ...

  6. 编程实战——电影管理器之利用MediaInfo获取高清视频文件的相关信息

    随着高速(20M)宽带.HTPC.大容量硬盘(3T)的普及,下载高清片并利用大屏幕观看也成为普通的事情. 随着下载影片的增多,管理就有了问题,有时在茫茫文件夹下找寻一个影片也是一件费时费力的事. 于是 ...

  7. Python实例获取mp3文件的tag信息

    下面利用一个python的实例程序,来学习python.这个程序的目的就是分析出所有MP3文件的Tag信息并输出. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...

  8. FtpHelper类匿名获取FTP文件

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net ...

  9. Linux基础命令---get获取ftp文件

    get 使用lftp登录ftp服务器之后,可以使用get指令从服务器获取文件.   1.语法       get [-E]  [-a]  [-c] [-O base]  rfile  [-o lfil ...

随机推荐

  1. hdu1075What Are You Talking About (字典树)

    Problem Description Ignatius is so lucky that he met a Martian yesterday. But he didn't know the lan ...

  2. QT操作Excel(通过QAxObject使用了OLE,前提是本地安装了Excel)

    新建QT GUI项目,在选择选项中勾选ActiveQT Container. #include <qaxobject.h> QAxObject *obj = new QAxObject(& ...

  3. 为VisualSVN Server增加在线修改用户密码的功能

    原文:为VisualSVN Server增加在线修改用户密码的功能 附件下载:点击下载 VisualSVN Server是一个非常不错的SVN Server程序,方便,直观,用户管理也异常方便. 不过 ...

  4. 依据不同的操作系统读取配置文件/java读取属性文件代码

    package cn.com.css.common.util; /**  * @brief OSEnum.java 操作系统的枚举  * @attention  * @author 涂作权  * @d ...

  5. [Android学习笔记]LayoutParams的使用

    LayoutParams的使用: 什么时候会用到此对象?动态布局,动态向ViewGroup中添加子view时,为子view设置此对象,目的是告诉父容器以何种方式呈现此子view LayoutParam ...

  6. [C++]C++中的运行时类型检测

    Date:2014-1-3 Summary: 使用C++中的运行时类型检测.(文章重点在于记录本人的使用情况,并非深层讨论RTTI) Contents:写习惯C#的我,在C++依然存在哪些.NET的惯 ...

  7. Android中特殊图形的生成样例

    import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; impor ...

  8. 算法起步之Prim算法

    原文:算法起步之Prim算法 prim算法是另一种最小生成树算法.他的安全边选择策略跟kruskal略微不同,这点我们可以通过一张图先来了解一下. prim算法的安全边是从与当前生成树相连接的边中选择 ...

  9. [Backbone]Make Backbone Better With Extensions

    Backbone is becoming wildly popular as a web application development framework. Along with this popu ...

  10. Android设备管理器漏洞2--禁止用户取消激活设备管理器

    2013年6月,俄罗斯安全厂商卡巴斯基发现了史上最强手机木马-Obad.A.该木马利用了一个未知的Android设备管理器漏洞(ANDROID-9067882),已激活设备管理器权限的手机木马利用该漏 ...