使用Vb.net桌面应用程序复制多个文件 [英] Copy more than one files using Vb.net desktop application

查看:181
本文介绍了使用Vb.net桌面应用程序复制多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码将文件从一个文件夹复制到另一个文件夹.
这不是完整的代码

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

推荐答案

快速答案是,您需要将MultiSelect属性设置为true.然后,用户可以选择多个文件,然后可以循环浏览它们并将它们复制到其他位置.

这是与您类似的问题,并附有正确答案:

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[^]


使用
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);
	}
}


这篇关于使用Vb.net桌面应用程序复制多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆