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

    }

  • 相关阅读:
    懒加载数据,在取出数据时容易出的bug....
    小程序申请及小程序发布
    SSL证书申请及安装
    iview modal 覆盖问题
    取消div独占一行的特性
    GPS坐标互转:WGS-84(GPS)、GCJ-02(Google地图)、BD-09(百度地图)、(百度坐标转谷歌坐标)
    工厂方法模式
    STS创建SpringBoot项目
    snmp协议学习记录
    操作系统命令学习记录
  • 原文地址:https://www.cnblogs.com/Events/p/3309851.html
Copyright © 2011-2022 走看看