copy files from clipboard

X

Xavier Valdés

Hi all,

I would like to copy FILES from the clipboard to a desired folder from
VB.NET.
I was able to copy files (with filedrop data format) to the clipboard but I
don't know
how to catch this data (the entire data) and leave it (copy it) to a folder.
It doen't matter if the data I want to copy is a folder, a file or a group
of them. The
fact is I would like to copy the WHOLE data with a function.
Any ideas?
Thanks a lot,
Xavier Valdés
 
C

Cor Ligthert

Xavier,

I saw that I had an old sample I once made

\\\
'Copy with windows explore some files and than this
Private Sub Button1_Click(ByVal sender _
As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim folderbrowserDialog1 As New FolderBrowserDialog
Dim iData As IDataObject = Clipboard.GetDataObject()
If iData.GetDataPresent(DataFormats.FileDrop) Then
Dim clipbrd As String() = DirectCast(iData.GetData(DataFormats.FileDrop),
String())
Dim i As Integer
folderbrowserDialog1.ShowDialog()
For i = 0 To clipbrd.Length - 1
If System.IO.File.Exists(folderbrowserDialog1.SelectedPath _
& System.IO.Path.GetFileName(clipbrd(i))) Then
System.IO.File.Move(folderbrowserDialog1.SelectedPath & _
"\" & _
System.IO.Path.GetFileName(clipbrd(i)), _
folderbrowserDialog1.SelectedPath & "temptemptemp.temp")
End If
System.IO.File.Copy(clipbrd(i), folderbrowserDialog1.SelectedPath & _
"\" & _
System.IO.Path.GetFileName(clipbrd(i)))
If System.IO.File.Exists(folderbrowserDialog1.SelectedPath _
& "temptemptemp.temp") Then
System.IO.File.Delete(folderbrowserDialog1.SelectedPath & _
"temptemptemp.temp")
End If
///

I hope this helps?

Cor
 
X

Xavier Valdés

Thanks a lot,
Cor!

Cor Ligthert said:
Xavier,

I saw that I had an old sample I once made

\\\
'Copy with windows explore some files and than this
Private Sub Button1_Click(ByVal sender _
As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim folderbrowserDialog1 As New FolderBrowserDialog
Dim iData As IDataObject = Clipboard.GetDataObject()
If iData.GetDataPresent(DataFormats.FileDrop) Then
Dim clipbrd As String() = DirectCast(iData.GetData(DataFormats.FileDrop),
String())
Dim i As Integer
folderbrowserDialog1.ShowDialog()
For i = 0 To clipbrd.Length - 1
If System.IO.File.Exists(folderbrowserDialog1.SelectedPath _
& System.IO.Path.GetFileName(clipbrd(i))) Then
System.IO.File.Move(folderbrowserDialog1.SelectedPath & _
"\" & _
System.IO.Path.GetFileName(clipbrd(i)), _
folderbrowserDialog1.SelectedPath & "temptemptemp.temp")
End If
System.IO.File.Copy(clipbrd(i), folderbrowserDialog1.SelectedPath & _
"\" & _
System.IO.Path.GetFileName(clipbrd(i)))
If System.IO.File.Exists(folderbrowserDialog1.SelectedPath _
& "temptemptemp.temp") Then
System.IO.File.Delete(folderbrowserDialog1.SelectedPath & _
"temptemptemp.temp")
End If
///

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top