I have a text file where I save a line every 30 minutes with the WriteLineAsync method. When the file become too large, if I try to read it, the application crashes. I thought that I could limit the lines writable on the file so when I add a new line, the oldest line will be deleted. How can I do that?
edit: I read the file with the following code:
StorageFile MyFile = await ApplicationData.Current.LocalFolder.GetFileAsync("LogFile.txt");
string nextLine;
using (StreamReader reader = new StreamReader(await MyFile.OpenStreamForReadAsync()))
{
while ((nextLine = await reader.ReadLineAsync()) != null)
{
TextLog.Text += nextLine + "\n";
}
}
I've tried to debug it and I don't get any exception from the reading code. Maybe the problem is that I try to put all that text in a textblock.