using System; using System.IO; using System.Text; using System.Windows.Forms; public static class ClipboardFusionHelper { public static string ProcessText(string text) { //if ClipboardFusion gave us string data, just return that if(!string.IsNullOrEmpty(text)) return text; //get the data object that is on the clipboard IDataObject dataObject = Clipboard.GetDataObject(); //enumerate through all of the different clipboard formats foreach(string format in dataObject.GetFormats()) { //try to get a memory stream from the clipboard MemoryStream stream = dataObject.GetData(format) as MemoryStream; //if we couldn't convert to a memory stream, continue to the next format if(stream == null) continue; //get the data from the stream and convert it to an ASCII string byte[] data = new byte[stream.Length]; stream.Read(data, 0, data.Length); return Encoding.ASCII.GetString(data); } throw new Exception("Unable to get MemoryStream"); } }