/// <summary> /// Tries to determine the format of the data in the clipboard and parse it. /// <para>Supports comma separated values.</para> /// </summary> public static List <string[]> ParseClipboardData() { // get the data IDataObject dataObject = Clipboard.GetDataObject(); if (dataObject == null) { return(new List <string[]>()); } // set the parsing method (based on the format) // currently works with CSV and Text data formats string clipboardString; { string[] formats = dataObject.GetFormats(); if (formats.Contains(DataFormats.CommaSeparatedValue)) { clipboardString = (string)dataObject.GetData(DataFormats.CommaSeparatedValue); } else if (formats.Contains(DataFormats.StringFormat)) { clipboardString = (string)dataObject.GetData(DataFormats.StringFormat); } else if (formats.Contains(DataFormats.UnicodeText)) { clipboardString = (string)dataObject.GetData(DataFormats.UnicodeText); } else if (formats.Contains(DataFormats.Text)) { clipboardString = (string)dataObject.GetData(DataFormats.Text); } else { return(new List <string[]>()); } } return(CsvUtility.Parse(clipboardString).ToList()); }