Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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[^]
 
Share this answer
 
Comments
Manas Bhardwaj 21-Jun-12 7:41am    
correct +5!
Maciej Los 21-Jun-12 12:36pm    
Good answer, my 5!
MacParekh 25-Jun-12 6:20am    
Thanks
Use the Multiselect [^]property and loop through the FileName list.

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

C#
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);
	}
}
 
Share this answer
 
v2
Comments
Prasad_Kulkarni 21-Jun-12 7:49am    
My 5!
Maciej Los 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900