将文件复制到不同的目录 [英] Copy file to a different directory

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

问题描述

我的工作,我想一些文件在一个目录复制到第二个已经存在的目录中的项目。

我无法找到一个方法来简单地从一个文件夹复制到另一个。我能找到将文件复制到一个新的文件或目录到一个新的目录。

我有我的程序设定,现在是我复制的文件,并把它留在同一个目录的方式,然后移动该副本到我想要的目录。

编辑:

谢谢大家。所有答案的工作。我意识到我做错了什么,当我设定的目标路径我没有添加一个文件名。一切正常,现在,感谢您的超快速响应。

解决方案

  File.Copy(@someDirectory \ someFile.txt,@otherDirectory \ someFile.txt);
 

工作正常。

I am working on a project where I want to copy some files in one directory to a second already existing directory.

I can't find a way to simply copy from one folder to another. I can find copy file to a new file, or directory to a new directory.

The way I have my program set up right now is I copy the file and leave it in same directory, then move that copy to the directory that I want.

Edit:

Thanks everyone. All of your answers worked. I realized what I did wrong, when i set the destination path I didn't add a filename. Everything works now, Thanks for the super speedy responses.

解决方案

File.Copy(@"someDirectory\someFile.txt", @"otherDirectory\someFile.txt");

works fine.

这篇关于将文件复制到不同的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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