I didn’t know anything about .net I/O until I started this last night, though having 30 years of programming experience helped me to figure out the best (?) direction to go as I was learning.
Managed code is a lot easier than the old way, but the learning curve is indeed fiercer. dotnet / C# programming is the summation of 40 years of API and language design and the concepts are not easy to understand.
It is, actually. In your project settings set API Compatibility Level to .Net 2.0 and then use the standard .Net I/O functionality.
How to write files:
using (var writer = new BinaryWriter(File.Open(filename, FileMode.CreateNew)))
{
writer.Write(123);
writer.Write(123.456f);
writer.Write("Hello, World!");
}
How to read files:
using (var reader = new BinaryReader(File.Open(filename, FileMode.Open)))
{
var integer = reader.ReadInt32();
var real = reader.ReadSingle();
var text = reader.ReadString();
}
Also check File.ReadAllText, File.ReadAllLines, File.WriteAllText, File.WriteAllLines inside System.IO namespace.