FileReadWriter provide easy way to read/write file. Ex, when output path has not existing directory, it will be created.
NOTE: This project is made by Unity, but it FileReadWriter.cs
works on a native C#.
You can import this asset from UnityPackage.
Import FileReadWriter/FileReadWriter.cs
to your project.
FileReadWriter.cs
is static class. So you can call any method from any place.
public string filePath = "~";
public string fileContent = "Sample";
protected string result = "";
result = FileReadWriter.ReadFile(filePath).content;
result = FileReadWriter.WriteFile(filePath, fileContent).content;
Default encoding is UTF-8
but you can change the encoding with argument if you need.
And in default, When output path has not existing directory, it will be created.
This is useful to avoid Not found exception
.
Also this setting is enabled to change with argument too.