我有一个图片框,如果我使用下面的代码片段:
Clipboard.SetImage(PictureBox.image)
那么我只能把这个图片复制到像画图和微软Word这样的软件中,而不能把它作为一个文件粘贴到文件夹或桌面上。
那么如何将图片复制到剪贴板中,并使其可以粘贴到文件夹中变成一个文件呢?
SetFileDropList
将临时文件添加到剪贴板。' Add it as an image
Clipboard.SetImage(PictureBox1.Image)
'Create a JPG on disk and add the location to the clipboard
Dim TempName As String = "TempName.jpg"
Dim TempPath As String = System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.Temp, TempName)
Using FS As New System.IO.FileStream(TempPath, IO.FileMode.Create, IO.FileAccess.Write, IO.FileShare.Read)
PictureBox1.Image.Save(FS, System.Drawing.Imaging.ImageFormat.Jpeg)
End Using
Dim Paths As New System.Collections.Specialized.StringCollection()
Paths.Add(TempPath)
Clipboard.SetFileDropList(Paths)