aychekay
Member
- Joined
- Oct 10, 2011
- Messages
- 11
- Programming Experience
- 3-5
I'm not too handy with .Net since I do most of my work in MS Access. How can I save a screenshot to a file in a console application (or a code library)? The code I've found uses objects that seem to be specific to the Windows.Forms namespace and I can't seem to import them.
Here's the code I do have. It works on a Windows Form project. I'm using Visual Studio 2008, by the way.
Here's the code I do have. It works on a Windows Form project. I'm using Visual Studio 2008, by the way.
VB.NET:
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)
Dim sFilename As String = Path.GetTempFileName()
oImgObj.Save(sFilename, System.Drawing.Imaging.ImageFormat.Gif)
End If
End If