Pacman Pacman - 3 months ago 20
C# Question

Getting clipboard data from remote computer

Using C#, is there a way to get the clipboard data that is on a remote machine ?
I am remoting into another computer using Remote Desktop, I run an application on it that copies some text onto the clipboard, from my desktop I have a C# winform application that needs to make use of the clipboard data on that remote machine.

Is there a way to do that ?

Answer

You can use the Clipboard object in C#, Refer: https://msdn.microsoft.com/en-us/library/c2thcsx4(v=vs.110).aspx

//Set data to clipboard
Clipboard.SetData(format, users);
//Get data from clipboard
List<User> result = null;
if (Clipboard.ContainsData(format)){
    result = (List<User>)Clipboard.GetData(format);
}
//Clear clipboard
Clipboard.Clear();