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

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

问题描述

我需要将一个文件复制到另一个路径,保留原来的位置.

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:	est.txt", @"c:	estfoo.txt");

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

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

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