将项目文件复制到驱动器上的指定位置 [英] copy project file to specified location on drive

查看:98
本文介绍了将项目文件复制到驱动器上的指定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好..
我正在使用Windows应用程序.我想以编程方式将项目中可用的文件复制到驱动器上的指定位置.
你能帮我吗?

Hello..
I''m working on windows app. I wanna programatically copy the file which is available in project to specified location on drive.
Can u help me?

推荐答案


试试这个代码:
System.IO.File.Copy(字符串源文件名,字符串目标文件名);
sourcefilename:要复制的文件的路径和全名.
destfilename:path和完整的新名称作为目的地.

try this code:
System.IO.File.Copy(string sourcefilename,string destfilename);
sourcefilename:path and full name of file to copy.
destfilename:path and full new name as destination.


这是针对Web应用程序的:

HttpPostedFile hpf;
hpf.SaveAs(Server.MapPath("PathDirectoryYouWantToSaveYourFileIn")+"\\" + Path.GetFileName("FileName"));
This is for Web Application:

HttpPostedFile hpf;
hpf.SaveAs(Server.MapPath("PathDirectoryYouWantToSaveYourFileIn") + "\\" + Path.GetFileName("FileName"));


尝试:
File.Copy(pathSource, pathDestination, true);


详细信息: MSDN [ ^ ]


Details: MSDN[^]


这篇关于将项目文件复制到驱动器上的指定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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