Click here to Skip to main content
12,448,563 members (55,647 online)
Rate this:
 
Please Sign up or sign in to vote.
I am using below code for copy file from one folder to another.
This is not full code
If OpenFile.ShowDialog() = Windows.Forms.DialogResult.OK Then
    Me.TxtFilePath.Text = OpenFile.FileName
End If
Dim fiinfo As FileInfo
 
TempFilePath = Me.TxtFilePath.Text.Trim()
PathforServer = "D:\"
fiinfo = New FileInfo(TempFilePath)
 
fiinfo.CopyTo("D:\foldername\", True)

By this code i can upload only one file.
I want to upload more than one files at a time
how can i solve this problem?

Thanks in advance
Posted 21-Jun-12 1:21am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

The quick answer is that you need to set the MultiSelect property to true. Then the user can select multiple files and you can loop through them and copy them to the other location.

Here is a question similar to yours with the correct answer attached:

http://www.daniweb.com/software-development/vbnet/threads/342763/allow-user-to-select-multiple-files-from-one-directory-and-place-them-in-another[^]
  Permalink  
Comments
Manas Bhardwaj 21-Jun-12 7:41am
   
correct +5!
losmac 21-Jun-12 12:36pm
   
Good answer, my 5!
MacParekh 25-Jun-12 6:20am
   
Thanks
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Use the Multiselect [^]property and loop through the FileName list.

Something like this. The code is in C#, but should give you an idea.

OpenFileDialog dlg = new OpenFileDialog();
dlg.Multiselect = true;
 
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
	foreach (string file in dlg.FileNames)
	{
		FileInfo fileInfo = new FileInfo(file);
		fileInfo.CopyTo(@"D:\foldername\", true);
	}
}
  Permalink  
v2
Comments
Prasad_Kulkarni 21-Jun-12 7:49am
   
My 5!
losmac 21-Jun-12 12:36pm
   
Good answer, my 5!
MacParekh 25-Jun-12 6:20am
   
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160811.3 | Last Updated 21 Jun 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100