|
-
Jun 11th, 2007, 02:39 AM
#1
Thread Starter
Addicted Member
[RESOLVED] My.Computer.FileSystem.CopyFile
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim result As DialogResult = Me.OpenFileDialog1.ShowDialog()
If result = Windows.Forms.DialogResult.OK Then
For Each sFilePath As String In Me.OpenFileDialog1.FileNames
Me.ListBox1.Items.Add(sFilePath)
Next sFilePath
End If
End Sub
Private Function getFileName(ByVal sFilePath As String) As String
Dim iLenFilePath As Integer = sFilePath.Length
Dim iLastSlashPos As Integer = Strings.InStrRev(sFilePath, "textbox1.text")
Return Strings.Right(sFilePath, iLenFilePath - iLastSlashPos)
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For i As Integer = 0 To Me.ListBox1.SelectedItems.Count - 1
Dim sFileName = getFileName(Me.ListBox1.SelectedItems.Item(i))
Try
My.Computer.FileSystem.CopyFile(Me.ListBox1.SelectedItems.Item(i), "textbox1.text" & sFileName)
MessageBox.Show("Copy was successfull for file " & sFileName)
Catch ex As Exception
MessageBox.Show("Error while copying file " & sFileName & vbNewLine & "Error message: " & ex.Message)
End Try
Next i
End Sub
hello this is my code
I can select files to A listbox, but now have to copy them one by one
to the directory I have choose in textbox1.text(the location), but how can I copie the selected files that in the listbox at the same time
so I have selected the files That I wont to copy
I say In the textbox1.text the location where to copy the files
end now I want to have i button to copy the selected files At one time In the directory where to copy can someon help me
Last edited by NeedHelp01; Jun 11th, 2007 at 02:42 AM.
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
|