如何将文件复制到其他路径? [英] How to copy a file to another path?

查看:196
本文介绍了如何将文件复制到其他路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将文件复制到其他路径,离开原来它在哪里。

I need to copy a file to another path, leaving the original where it is.

我也希望能够重命名的文件。

I also want to be able to rename the file.

威尔FileInfo中CopyTo方法工作的?

Will FileInfo's CopyTo method work?

推荐答案

有一个看的 File.Copy()

使用File.Copy您可以指定新的文件名作为目标字符串的一部分。

Using File.Copy you can specify the new file name as part of the destination string.

因此​​,像

File.Copy(@"c:\test.txt", @"c:\test\foo.txt");

另请参见如何:复制,删除,移动文件和文件夹(C#编程指南)

这篇关于如何将文件复制到其他路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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