- Home /
Question by
DiGiaCom-Tech · May 08, 2018 at 04:30 PM ·
encodingfile sizeascii
Trouble Loading a 200K+ Text File Into a String...
I have a game save file that I am reading and parsing for the saved information. The code for this...
private void LoadSaveText()
{
// Get the contents of the file
file_bytes = File.ReadAllBytes(FileManager.Instance.FilePathName);
file_size = file_bytes.Length;
file_get = file_size - file_offset;
file_text = System.Text.Encoding.ASCII.GetString(file_bytes, file_offset, file_get);
}
... which has been working flawlessly until recently.
What is happening now is that it only reads the top most part of the file (almost 3k) into the string when the length of the files is over 207k.
Am I doing something wrong here? Could special characters in the file_bytes array be preventing the full array from being converted? Anyone have any ides and/or suggestions on how I should be reading this file into a string?
Comment
I heard about problems encoding and decoding strings that are too large. Try to serialize the string via BinaryFormatter.