我刚开始学习VB,我想创建一个程序来保存我的剪贴板(ProntScreen)。我已经成功了,但是我想为这些图像生成文件名,所以我可以将它们中的很多放到同一个文件夹中,而无需更改源代码。
这是我的代码:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Not System.Windows.Forms.Clipboard.GetDataObject() Is Nothing Then
Dim oDataObj As IDataObject = System.Windows.Forms.Clipboard.GetDataObject()
If oDataObj.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap) Then
Dim oImgObj As System.Drawing.Image = oDataObj.GetData(DataFormats.Bitmap, True)
'To Save as Bitmap
'oImgObj.Save("c:\Test.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
'To Save as Jpeg
oImgObj.Save("d:\Test\test.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg)
'To Save as Gif
'oImgObj.Save("c:\Test.gif", System.Drawing.Imaging.ImageFormat.Gif)
End If
End If
End Sub
End Class
如您所见,图像已保存到D:\Test\Test.jpeg
我要生成文件名(test.jpeg)的修复位置。也许当前时间会像 114512 或类似的东西很酷