C# 剪贴板

图片保存到本地

1     IDataObject data = Clipboard.GetDataObject();
2     if (data != null && data.GetDataPresent(typeof(Bitmap)))
3     {
4         Image image = (Image)data.GetData(typeof(Bitmap));
5         image.Save(imageFilePath, ImageFormat.Png);
6         image.Dispose();
7     }

获取文件列表

 1     if (Clipboard.ContainsFileDropList())
 2     {
 3         var fileDropList = Clipboard.GetFileDropList();
 4         foreach (var file in fileDropList)
 5         {
 6             if (!string.IsNullOrEmpty(AttachmentsTextBox.Text))
 7             {
 8                 AttachmentsTextBox.Text += "\r\n";
 9             }
10             AttachmentsTextBox.Text += file;
11         }
12     }

 

posted @ 2024-08-22 18:03  唐宋元明清2188  阅读(11)  评论(0编辑  收藏  举报