zoukankan      html  css  js  c++  java
  • C#获取FTP文件详细备注信息

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

    }

  • 相关阅读:
    ABP无法使用异步操作,但要调用异步方法
    ABP 领域服务层学习记录
    Postman 简单使用随笔记
    Abp 模板更换数据库 版本为V5.x,遇到的问题
    C# 求两个时间的差值
    Mysql 为现有数据生成Guid
    设计模式之单例模式
    iOS基础(十八)——调整图片尺寸和大小
    iOS基础(十七)——根据一个View生成一个image
    iOS基础(十六)——动态获取label的高度
  • 原文地址:https://www.cnblogs.com/Events/p/3309851.html
Copyright © 2011-2022 走看看