Saving and loading raw strings and bytes
Easy Save allows you to save string and bytes directly to a file using ES3.SaveRaw and ES3.AppendRaw.
You can also read a file as a string or byte array using ES3.LoadRawString or ES3.LoadRawBytes.
Raw strings
1 2 3 4 5 6 7 8 9 10 11 12 |
// Create a string which represents three lines in a text file. string myString = "Line1\nLine2\nLine3"; // Save the string as a file. ES3.SaveRaw(myString, "myFile.txt"); // Append another line to the file. ES3.AppendRaw("\nLine4", "myFile.txt"); // Now load the file back. // This string will be "Line1\nLine2\nLine3\nLine4" myString = ES3.LoadRawString("myFile.txt"); |
Raw bytes
1 2 3 4 5 6 7 8 9 10 11 |
// Create some bytes which we wish to store to a file. byte[] myBytes = GetBytes(); // Save the bytes as a file. ES3.SaveRaw(myBytes, "myFile.bytes"); // Append more bytes to the file. ES3.AppendRaw(GetMoreBytes(), "myFile.bytes"); // Now load the file back as a byte array. myBytes = ES3.LoadRawBytes("myFile.bytes"); |