将目录复制到输出目录 - 控制台应用程序 .NET

发布于 2024-07-08 18:34:55 字数 147 浏览 5 评论 0原文

有没有办法将整个目录复制到 C#.NET 控制台应用程序中的输出目录?

我知道对于文件,您可以右键单击它们,属性并标记复制到输出目录。 但我不会对 20.000 个文件这样做...

谢谢,Lieven Cardoen aka Johlero

Is there a way to copy an entire directory to the output directory in a console application in C#.NET?

I know for files you can right click them, properties and mark copy to output directory. But I'm not going to do that for 20.000 files...

Thx, Lieven Cardoen aka Johlero

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

生死何惧 2024-07-15 18:34:55
  1. 在开发过程中,使用应用程序配置来指向这些文件当前所在的位置,而不是复制它们。 (在每个构建上复制这么多对象是一场噩梦。即使只复制新的/更新的文件)

  2. 在准备发布构建时,您可能需要考虑使用构建脚本和 MSBuild 或 NAnt 来执行此类操作

  3. 如果您真的确信您仍然想在每个构建上执行复制 - 使用后/预构建脚本(在您的项目构建配置中,指向执行 xcopy 的批处理文件..一些智能批处理脚本有时非常有帮助)。

  1. While in development, use application configuration to point to where these files CURRENTLY reside, instead of copying them. (copying that many objects on each build is a nightmare. Even if copying only new/updated files)

  2. When preparing a release build, you might want to consider using a build script and MSBuild or NAnt to do this type of thing for you.

  3. If you REALLY are convinced you are sure you still want to perform a copy on each build - use Post/pre-build script (in your project build configuration, point to a batch file which performs an xcopy.. some smart batch scripting can sometimes be very helpful).

阪姬 2024-07-15 18:34:55

您确定要输出所有 20000 个文件吗?

除了手动复制粘贴操作之外,我还看到两个选项:一个是您可以执行构建后任务来复制所有文件,另一个是压缩 20000 个文件,将 zip 文件作为内容项添加到您的项目中,并使用“始终复制”设置并控制台应用程序解压缩它们,或者构建后步骤调用解压缩实用程序来执行此操作。

Are you sure you want all 20000 files in the output?

Besides manual copy-paste operation I see two options: one is you can have a post-build task to copy all the files and another is to have 20000 files zipped, zip file added as a content item to your project with "copy always" set and either console application unzip 'em, or a post-build step is calling unzip utility to do that.

南薇 2024-07-15 18:34:55

您可以按 ctrl+A 突出显示所有内容,然后按 ctrl+C 复制它们,然后转到新目录并按 ctrl+V 将它们全部粘贴到新位置...

或者您可以打开命令窗口并使用复制...但第一种方法可能更容易。

You could hit ctrl+A to highlight all of them, then hit ctrl+C to copy them, then go to the new directory and hit ctrl+V to paste them all to the new location...

Or you could open up the command window and use copy... but the first way is probably easier.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文