How to press a button in the program window to put a picture from the disk to the clipboard?
1 answer
Easy peasy.
For WinForms use
using System.Windows.Forms; using System.Drawing; Clipboard.SetImage(Image.FromFile(path)); For WPF, use
using System.Windows; Clipboard.SetImage(new BitmapImage(new Uri(path))); Yes, in both cases, you need to run this function from the STA stream. For example, from a UI stream. If this is a workflow, call .SetApartmentState(ApartmentState.STA) on it. You cannot run this in the thread pool because the threads from the pool are not STA threads.
|