windows 在 MFC 应用程序中,将文件从一个目录复制到另一个目录的最简单方法是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/191980/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:26:12  来源:igfitidea点击:

In an MFC application, what's the easiest way to copy a file from one directory to another?

c++windowsmfcfile

提问by Tommy Herbert

Should I create two CFile objects and copy one into the other character by character? Or is there something in the library that will do this for me?

我应该创建两个 CFile 对象并逐个字符地将一个对象复制到另一个对象中吗?或者图书馆里有什么东西可以为我做这件事?

回答by jeffm

I would just use the CopyFileWin32 API function, but the example code in the CFile::Opendocumentation shows how to copy files with CFile (using pretty much the method you suggest).

我只会使用CopyFileWin32 API 函数,但CFile::Open文档中的示例代码显示了如何使用 CFile 复制文件(几乎使用您建议的方法)。

回答by skst

It depends on what you want to do. There are a number of ways to copy files:

这取决于你想做什么。有多种方法可以复制文件:

  • CopyFile()
  • CopyFileEx()
  • SHFileOperation()
  • IFileOperation (replaces SHFileOperation() in Vista)
  • 拷贝文件()
  • 复制文件Ex()
  • SHFileOperation()
  • IFileOperation(取代 Vista 中的 SHFileOperation())