Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Copy file to clipboard
#3
I have never worked with the Clipboard object before. So, I found this code snippet online. I hope it helps!
[code2=vbnet]Public Function ClipboardCopyFiles(ByVal Files() As String) As Boolean

Dim dataObject As New DataObject
Dim varObject(0) As String

Dim fileName As String
Dim idxFile As Integer
Dim scriptingFile As Scripting.File
Dim fileSysObject As New Scripting.FileSystemObject

Try
'Clipboard.SetDataObject(New DataObject)
For idxFile = LBound(Files) To UBound(Files) - 1
If Not (Files(idxFile) Is Nothing) Then
scriptingFile = fileSysObject.GetFile(Files(idxFile).ToString())
fileName = scriptingFile.ShortPath
End If
Next
'//
varObject(0) = fileName
dataObject.SetData(DataFormats.FileDrop, False, varObject)
Clipboard.SetDataObject(dataObject)
'//
ClipboardCopyFiles = True
Catch ex As Exception
MsgBox(ex.Source & " : " & ex.Message)
ClipboardCopyFiles = False
Throw ex
End Try

End Function[/code2]

[Copied from <!-- m --><a class="postlink" href="http://www.developerfusion.com/thread/44352/copy-file-to-clipboard-and-use-clipboard-object-in-vbnet-2/">http://www.developerfusion.com/thread/4 ... n-vbnet-2/</a><!-- m -->]
My Blog | My Setup | My Videos | Have a wonderful day.


Messages In This Thread
Copy file to clipboard - by brco900033 - 09-15-2012, 07:41 AM
Re: Copy file to clipboard - by Snake_eyes - 11-01-2012, 12:11 AM
Re: Copy file to clipboard - by brandonio21_phpbb3_import2 - 11-01-2012, 04:20 PM
Re: Copy file to clipboard - by brco900033 - 11-02-2012, 02:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rename application file brco900033 3 14,841 10-15-2013, 12:03 AM
Last Post: brandonio21
  getting a file name form a save dialoge zmanalpha 3 14,115 08-04-2012, 03:15 PM
Last Post: brandonio21
  External Settings File brco900033 1 8,775 11-04-2011, 02:47 PM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)