Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy and paste with C#

Tags:

c#

I know this is asked many times before but it s not what i look for, to make copy paste in c# we use;

//Copy
Clipboard.SetDataObject("String to copy"); 

//Paste
IDataObject iData = Clipboard.GetDataObject(); 

I only want to use copy, after using:

Clipboard.SetDataObject("String to copy"); 

when i close the program, then when i right click and paste on a txt file nothing happens!
So Clipboard class seems doesnt help, so i need another solution.

like image 967
Mustafa Ekici Avatar asked Feb 03 '26 15:02

Mustafa Ekici


1 Answers

Clipboard.SetDataObject("String to copy", true);

That boolean value at the end specifies whether the string should remain in the clipboard after the application closes, and is set to false as default.

like image 62
Andreas Eriksson Avatar answered Feb 05 '26 05:02

Andreas Eriksson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!