/// <summary> /// Store the string to the named, persistent backing file. /// </summary> /// <param name="Text"></param> public void Store(string Text) { using (SystemWideMutex locker = new SystemWideMutex(Name + "_mutex")) { locker.WaitOne(); System.IO.File.WriteAllText(this.BackingFilePath, Text); // signal an event indicating the string has been stored. StringStoredEvent.WaitHandle.Set(); } }
/// <summary> /// read and return the string stored in the backing file. /// </summary> /// <returns></returns> public string Recall() { string text = null; using (SystemWideMutex locker = new SystemWideMutex(Name + "_mutex")) { locker.WaitOne(); if (System.IO.File.Exists(this.BackingFilePath) == false) { text = ""; } else { text = System.IO.File.ReadAllText(this.BackingFilePath); } } return(text); }