Search code examples
windowsvisual-studio-2010mfcfile-copyingcfiledialog

Copying a CFileDialog file


I'm using a CFileDialog dialog box to open a file in my program. When this file gets opened, I'd also like to save a copy of that file into the directory of my program. How can I do this?

This is how I' m opening the file:

CFileDialog fileDlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, "All Files (*.*)|*.*||", this);

Thanks for any help.


Solution

  • The file dialog doesn't copy files. After it returns, you get the selected file, then use regular file copy API to copy the file.