zoukankan      html  css  js  c++  java
  • c# 文件的读写

        读文件:

     1 StreamReader sr = new StreamReader(FileName, Encoding.Default);
     2                 string content = "";
     3                 content = sr.ReadLine();
     4 
     5                 while (content != null)
     6                 {
     7                     //操作逻辑
     8                      ....
     9                      ....
    10                     content = sr.ReadLine();
    11                 }
    12                 sr.Close();
    View Code


     

       写文件:

     1             string path = @"路径list_key.txt";
     2 
     3             FileStream fs1 = new FileStream(path, FileMode.Create, FileAccess.Write);
     4            //创建写入文件 
     5             StreamWriter sw1 = new StreamWriter(fs1, Encoding.Default);
     6             sw1.AutoFlush = true;
     7 
     8            // for (int i = 0; i < strFirstList.Count; i++)
     9            // {
    10                // sw1.Write(strFirstList[i]);
    11                // sw1.Write(" ");
    12                // sw1.WriteLine(strSecList[i]);
    13             // }
    14 
    15 
    16             fs1.Close();
    View Code
  • 相关阅读:
    自定义Response
    并发编程之进程
    并发编程知识储备
    正则表达式和re模块
    Scrapy框架
    http协议和Chrome抓包工具
    requests库
    Beautifulsoup
    xpath
    Mysql一些操作
  • 原文地址:https://www.cnblogs.com/chengjunwei/p/3986097.html
Copyright © 2011-2022 走看看