|
-
Jun 18th, 2007, 03:31 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] [02/03] Copy Multiple Files To Clipboard
Using this code
im DataObject As New DataObject
Dim tempFileArray(0) As String
'NOTE THAT IT MUST BE PASSED AN ARRAY!!!
tempFileArray(0) = activeListView.SelectedItems(0).Tag
DataObject.SetData(DataFormats.FileDrop, False, tempFileArray)
Clipboard.SetDataObject(DataObject)
from this thread
http://vbforums.com/showthread.php?t...file+clipboard
I was able to copy a file and then paste it anywhere on my machine.
However, I need to be able to copy multiple files at once. Does anyone know how to accomplish this? I tried creating an ArrayList; didn't work. If I change the declaration to Dim tempFileArray(X) As String (X being ANY number), and change NOTHING else, it quits working. This, obviously, prevents from copying multiple files (or even one, for that matter). Sometimes it makes the Paste option enabled, but pasting produces no results.
Any ideas? I am stumped.
Thanks
VB.Net 2008
.Net Framework 2.0
"Must you breathe? 'Cause I need heaven..."
-
Jun 18th, 2007, 03:47 PM
#2
Re: [02/03] Copy Multiple Files To Clipboard
use an arraylist, and then cast it to an array of strings.
This works fine.
Code:
Dim DataObject As New DataObject
Dim tempFileArray As New ArrayList
'NOTE THAT IT MUST BE PASSED AN ARRAY!!!
tempFileArray.Add("C:\test1.txt")
tempFileArray.Add("C:\test2.txt")
DataObject.SetData(DataFormats.FileDrop, False, DirectCast(tempFileArray.ToArray(GetType(String)), String()))
Clipboard.SetDataObject(DataObject)
Note: replace my tempFileArray.Add() lines with your own.. I used test files on my C drive root...
-
Jun 18th, 2007, 03:54 PM
#3
Thread Starter
Fanatic Member
Re: [02/03] Copy Multiple Files To Clipboard
Thanks a lot.
DirectCast(tempFileArray.ToArray(GetType(String)), String())
That's the little bit that I was missing. I am pretty functional in VB (it's my job), but there are many intricacies that I do not know.
Thanks again.
VB.Net 2008
.Net Framework 2.0
"Must you breathe? 'Cause I need heaven..."
-
Jun 18th, 2007, 04:12 PM
#4
Re: [RESOLVED] [02/03] Copy Multiple Files To Clipboard
Just so you know, its MUCH easier in .NET 2.0 because you can use generics...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|