Easiest way to read from and write to files

后端 未结 12 1853
[愿得一人]
[愿得一人] 2020-11-22 08:04

There are a lot of different ways to read and write files (text files, not binary) in C#.

I just need something that is easy and uses the least amount of c

12条回答
  •  滥情空心
    2020-11-22 08:24

    Or, if you are really about lines:

    System.IO.File also contains a static method WriteAllLines, so you could do:

    IList myLines = new List()
    {
        "line1",
        "line2",
        "line3",
    };
    
    File.WriteAllLines("./foo", myLines);
    

提交回复
热议问题