vb.net - How to generate filename for an image that have been saved from clipboard? VisualBasic -


i started to learn vb, , wanted create program saves clipboard (prontscreen). i've succeed there, want generate filename images, can take lot of them same folder without changing source code.

here code:

    public class form1 private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click     if not system.windows.forms.clipboard.getdataobject() nothing         dim odataobj idataobject = system.windows.forms.clipboard.getdataobject()         if odataobj.getdatapresent(system.windows.forms.dataformats.bitmap)             dim oimgobj system.drawing.image = odataobj.getdata(dataformats.bitmap, true)             'to save bitmap             'oimgobj.save("c:\test.bmp", system.drawing.imaging.imageformat.bmp)             'to save jpeg             oimgobj.save("d:\test\test.jpeg", system.drawing.imaging.imageformat.jpeg)             'to save gif             'oimgobj.save("c:\test.gif", system.drawing.imaging.imageformat.gif)         end if     end if end sub end class 

as can see image saved fix location d:\test\test.jpeg want generate filename (test.jpeg). maybe current time cool 114512 or that

i not vb person, work on c# let me give shot. declare system.datetime variable , store current datetime in that. declare string variable, lets call imagepath. in string variable construct path joining folder path(d:\test\", timestand, image extention(.jpeg). use imagepath variable in .save methond pass path , name. below code this, told this first time trying vb code. there can mistakes in code logic remains same, please change code if there mistakes.

dim timestamp system.datetime timestamp = now;  dim imagepath string imagepath = "d:\test\" + timestamp + ".jpeg";  oimgobj.save(imagepath, system.drawing.imaging.imageformat.jpeg) 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -