Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Copy file to clipboard
#1
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
#2
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...
#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.
#4
I tried and it worked for me. Thanks!
#5
brco900033 Wrote:I tried and it worked for me. Thanks!
No problem, glad we could solve your problem!
My Blog | My Setup | My Videos | Have a wonderful day.


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

Forum Jump:


Users browsing this thread: 1 Guest(s)