TextCopy is an open-source library for C# that simplifies interaction with the clipboard in .NET applications.
It is a lightweight and efficient tool, designed to work uniformly across different platforms, including Windows, macOS, and Linux.
TextCopy simplifies the tasks of copying and pasting text to and from the clipboard, offering a simple and straightforward API.
Installing TextCopy
To start using TextCopy in your .NET project, you first need to install the library via NuGet. You can do this through the NuGet Package Manager in Visual Studio or by using the NuGet console.
Install-Package TextCopy
How to Use TextCopy
Once you have installed TextCopy, you can start using it to copy and paste text in your application. The following are several examples illustrating how to interact with the clipboard using TextCopy.
Copy Text to the Clipboard
This example shows how to copy a text string to the clipboard.
using TextCopy;
class Program
{
static void Main(string[] args)
{
// Text to copy to the clipboard
string textToCopy = "Hello, world!";
// Copy the text to the clipboard
ClipboardService.SetText(textToCopy);
Console.WriteLine("Text copied to the clipboard.");
}
}
Paste Text from the Clipboard
This example shows how to paste (get) a text string from the clipboard.
using TextCopy;
class Program
{
static void Main(string[] args)
{
// Paste (retrieve) the text from the clipboard
string pastedText = ClipboardService.GetText();
Console.WriteLine($"Text pasted from the clipboard: {pastedText}");
}
}
TextCopy is Open Source and all its code and documentation are available in the project repository on GitHub - CopyText/TextCopy.

