public static void RemoveFromFile(string fileChars) { // base case: CLIPBOARD file is missing or empty if (!LocalClipboard.ClipboardFile.Exists || LocalClipboard.ClipboardFile.Length == 0) { return; } // store oldText, the old contents of the CLIPBOARD file string oldText; using (StreamReader sr = LocalClipboard.ClipboardFile.OpenText()) { oldText = sr.ReadToEnd(); } // newText = oldText - this item's FileChars string newText = LocalClipboard.ReplaceFirst(oldText, fileChars, ""); // replace old contents of the CLIPBOARD file with newText using (StreamWriter sw = LocalClipboard.ClipboardFile.CreateText()) { sw.Write(newText); } }