System.Windows.Forms.Clipboard.GetText Method

Retrieves text data from the Clipboard in the TextDataFormat.Text or TextDataFormat.UnicodeText format, depending on the operating system.

Syntax

public static string GetText ()

Returns

The Clipboard text data or string.Empty if the Clipboard does not contain data in the TextDataFormat.Text or TextDataFormat.UnicodeText format, depending on the operating system.

Remarks

This method returns text data in the TextDataFormat.UnicodeText format on WinXpFamily and Win2kFamily. Otherwise, this method returns text data in the TextDataFormat.Text format.

Use the erload:System.Windows.Forms.Clipboard.ContainsText method to determine whether the Clipboard contains text data before retrieving it with this method.

Use the erload:System.Windows.Forms.Clipboard.SetText method to add text data to the Clipboard.

Note:

The System.Windows.Forms.Clipboard class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your Main method is marked with the STAThreadAttribute attribute.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0