Easiest way to read from and write to files

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

    using (var file = File.Create("pricequote.txt"))
    {
        ...........                        
    }
    
    using (var file = File.OpenRead("pricequote.txt"))
    {
        ..........
    }
    

    Simple, easy and also disposes/cleans up the object once you are done with it.

提交回复
热议问题