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 code, because I am going to be working with files a lot in my project. I only need something for string
since all I need is to read and write string
s.
Or, if you are really about lines:
System.IO.File also contains a static method WriteAllLines, so you could do:
It's good when reading to use the OpenFileDialog control to browse to any file you want to read. Find the code below:
Don't forget to add the following
using
statement to read files:using System.IO;
To write files you can use the method
File.WriteAllText
.