How to read/write files in .Net Core?
Package: System.IO.FileSystem
System.IO.File.ReadAllText("MyTextFile.txt"); ?
FileStream fileStream = new FileStream("file.txt", FileMode.Open);
using (StreamReader reader = new StreamReader(fileStream))
{
string line = reader.ReadLine();
}
Using the System.IO.FileStream and System.IO.StreamReader. You can use System.IO.BinaryReader or System.IO.BinaryWriter as well.
To write:
using (System.IO.StreamWriter file =
new System.IO.StreamWriter(System.IO.File.Create(filePath).Dispose()))
{
file.WriteLine("your text here");
}