Easiest way to read from and write to files

后端 未结 12 1720
[愿得一人]
[愿得一人] 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:27

    FileStream fs = new FileStream(txtSourcePath.Text,FileMode.Open, FileAccess.Read);
    using(StreamReader sr = new StreamReader(fs))
    {
       using (StreamWriter sw = new StreamWriter(Destination))
       {
                sw.writeline("Your text");
        }
    }
    

提交回复
热议问题