Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void SaveRecentFile(string path)
- {
- LoadRecentList();
- if (!(RecentList.Contains(path)))
- RecentList.Enqueue(path);
- while (RecentList.Count > RecentListNumber)
- {
- RecentList.Dequeue();
- }
- StreamWriter stringToWrite = new StreamWriter(System.Environment.CurrentDirectory + "\\Recent.txt");
- foreach (string item in RecentList)
- {
- stringToWrite.WriteLine(item);
- }
- stringToWrite.Flush();
- stringToWrite.Close();
- }
- private void LoadRecentList()
- {
- RecentList.Clear();
- try
- {
- StreamReader listToRead = new StreamReader(System.Environment.CurrentDirectory + "\\Recent.txt");
- //read file stream
- string line;
- while ((line = listToRead.ReadLine()) != null) //read each line until end of file
- RecentList.Enqueue(line); //insert to list
- listToRead.Close(); //close the stream
- }
- catch (Exception)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement