|
-
Dec 1st, 2008, 03:51 PM
#1
Thread Starter
Fanatic Member
[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)
-
Dec 1st, 2008, 04:22 PM
#2
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()
That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma
Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney
-
Dec 1st, 2008, 04:25 PM
#3
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.
-
Dec 1st, 2008, 04:28 PM
#4
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.
-
Dec 1st, 2008, 11:58 PM
#5
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
-
Dec 2nd, 2008, 09:24 AM
#6
Thread Starter
Fanatic Member
Re: [2008] Copy Multiple Files without a loop
thks.
jmcilhinney: very well noted! thks
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
|