Posts: 96
Threads: 39
Joined: Sep 2011
Reputation:
0
Hi!
I have a question already. How can I copy a file to the clipboard? Not only the path or filename, but the whole file so you can actually paste the file onto your desktop or something.
Thanks in advance
Posts: 31
Threads: 2
Joined: Oct 2012
Reputation:
0
Why do you need to copy the file to the clipboard when there are many methods to simply copy or move a file from one location to another?
Sssssssssoftware developer...
Posts: 1,006
Threads: 111
Joined: Jul 2010
Reputation:
1
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 -->]
Posts: 96
Threads: 39
Joined: Sep 2011
Reputation:
0
I tried and it worked for me. Thanks!