c# – 有效复制多个文件
发布时间:2020-12-15 03:43:28 所属栏目:百科 来源:网络整理
导读:我必须将相当多的文件从一个文件夹复制到另一个文件夹.目前我正在这样做: string[] files = Directory.GetFiles(rootFolder,"*.xml");foreach (string file in files){ string otherFile = Path.Combine(otherFolder,Path.GetFileName(file)); File.Copy(fi
我必须将相当多的文件从一个文件夹复制到另一个文件夹.目前我正在这样做:
string[] files = Directory.GetFiles(rootFolder,"*.xml"); foreach (string file in files) { string otherFile = Path.Combine(otherFolder,Path.GetFileName(file)); File.Copy(file,otherFile); } 那是最有效的方式吗?似乎要花时间 编辑:我真的在问,是否有更快的方法来进行批量复制,而不是复制单个文件,但我猜答案是否定的. 解决方法
我不能想到一种比File.Copy更有效的方式,它直接转到操作系统.
另一方面,如果需要这么长时间,我强烈建议您展示一个进度对话框,如SHFileOperation为您而设.至少你的用户会知道发生了什么. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ajax,json,跨域jsonp总结
- 正则表达式 – 地址字段验证的正则表达式
- SqlMapConfig.xml中的setting属性设置
- c# – Visual Studio在StackOverflowException上丢失了第一
- JSONObject与JSONArray的使用
- 如何将类名作为变量传递给ruby中的另一个类
- sqlite错误处理:library routine called out of sequence
- c# – 使用RsaProtectedConfigurationProvider进行ProtectS
- vue-自定义组件传值的实例讲解
- DOJO TEST - Access to restricted URI denied“ code: ”1