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

    }

  • 相关阅读:
    Python socket 通信功能简介
    python2 && python3 的 input函数
    python 监听键盘输入
    std_msgs/String.msg
    python中string、json、bytes的转换
    python json与字典对象互相转换
    maven依赖关系中Scope的作用
    Maven项目下HttpServletRequest 或 HttpServletResponse需引用的依赖包
    Setup SS5 Socks Proxy
    Turn any Linux computer into SOCKS5 proxy in one command
  • 原文地址:https://www.cnblogs.com/Events/p/3309851.html
Copyright © 2020-2023  润新知