C#C
C#3y ago
uselessxp

✅ Clipboard.SetText in a ConsoleApp

Well, as a little task I'm trying to code a ConsoleApp that should base64 encrypt an input string and automatically copy it to the clipboard.

The ideal result is the following, by cmd:
  • -base64.exe -e string (for encrypt)
  • -base64.exe -d string (for decrypt)
First of all I'm playing with encoding/decoding and I figured out that I have to convert the input string into a byte (array?), then after I can apply the method that convert to base64.

What I'm unable to do, and that I always did in VB.NET Winforms, is Clipboard.SetText and I'm surprised to know that's strictly related to WinForms, since we're not talking abuot a button, or a textbox, but about the clipboard, that's global and abstract.

Btw from the Microsoft documentation (I'm trying to understand this one also if harder) I assumed two informations:

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms.dll

So as what I learned, I tried those steps:
1) add
using System.Windows.Forms;

2) add a COM reference to System.Windows.Forms

I don't know if I thought in the right way, but this seems not working.
image.png
image.png
image.png
Was this page helpful?