• 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
  • 相关阅读:
    1104
    HDU 1575
    hdu 1142(DFS+dijkstra)
    hdu 1015(DFS)
    hdu 1342(DFS)
    hdu 1181(DFS)变 形 课
    hdu 1312(DFS)
    hdu 5976 Detachment
    hdu 5795
    UVa 11729
  • 原文地址:https://www.cnblogs.com/chengjunwei/p/3986097.html
Copyright © 2020-2023  润新知