I need a way of clearing a text file after a certain period of time. This is what I have so far
List<string> previousWeaponList = new StreamWriter("PreviousList.txt");
So this is reading the previous weapon list into the file after a weapon is requested the weapon is written to that list. Once I do this I have a file which will get full very quickly if I save every single request, which is why I need to clean it out every X amount of time.
Would it be possible to do it like this?
private Thread fileCleaner;
public void FileCleaner()
{
fileCleaner = new Thread(new ThreadStart(this.Run))
}
Then just have a run function which if it's true it will just write to the file and then use a
Thread.Sleep();
I heard using Threads for time isn't a good idea, but I am not an expert on this.