[RESOLVED] [2008] Copy Multiple Files without a loop
Hi!!
Is it possible to copy multiple files without having to make use of a loop.
Right now the only way I know to copy multiple files is to loop through them like:
vb.net Code:
Dim Files As New List (Of String)
Files.AddRange(OPD.FileNames)
For a as Integer = 0 To Files.Count - 1
My.Computer.FileSystem.CopyFile(Files(a), "C:\APath\")
Next
Is there a way like:
vb.net Code:
Dim Files As New List (Of String)
Files.AddRange(OPD.FileNames)
My.Computer.FileSystem.CopyMultipleFile(Files, "C:\APath\")
(OPD is an openfiledialog)
Re: [2008] Copy Multiple Files without a loop
You could use cmd.exe to do this
Code:
'copy all files from A Path to B Path
Dim info As New ProcessStartInfo("cmd.exe", "/C copy C:\APath\* C:\BPath")
info.UseShellExecute = False
info.CreateNoWindow = True
Dim proc As New Process
proc.StartInfo = info
proc.Start()
Re: [2008] Copy Multiple Files without a loop
Why would you want to though? I dont think it'll be any more efficient, seeing as the harddrive can not read/write from more than one position at a time.
I could be wrong though.
Re: [2008] Copy Multiple Files without a loop
You can do a CopyDirectory() otherwise you're in a loop. I don't see why a loop is a bad thing though. If the .Net Framework provided a way to copy multiple files I'm sure it would use a loop.
Re: [2008] Copy Multiple Files without a loop
Given that OpenFileDialog.FileNames is a String array, what's the List(Of String) for? Why do you need to create a List to loop through when you've already got an array you can loop through?
vb.net Code:
For Each filePath As String In opd.FileNames
My.Computer.FileSystem.CopyFile(filePath, "C:\APath")
Next
Re: [2008] Copy Multiple Files without a loop
thks.
jmcilhinney: very well noted! thks