The error consists on an error box saying that it didn't find a file without a name (not exactly in those words because my OS is in spanish language, but that's basically what it says). I've also tried the CopyFile option without success. I have to include "Windows.h" with the headers, include Kernel32.lib in my project settings, and then i would have to put something like this: CopyFile('default.wav',PChar(strFile),TRUE); (am i right?) but it gives "error C2015: too many characters in constant" and error "C2065: 'PChar' : undeclared identifier" Well, i think it it is a little bit too late for me:zzz:. Tomorrow I will keep trying to find a solution.:)
Sousch
Posts
-
Best way to duplicate a file? -
Best way to duplicate a file?Hello, I'm having a problem when I try to save a file in a different directory (let's say that I simply want to duplicate the file). I have a "default.wav" in my directory and I use a dialog to save it (duplicate it) in another directory with a different name. This is my code: ============ CString strFile; (...) strFile = dlg.GetPathName(); (...) CFile file_orig,file_dest; char *pBuffer; (...) <- part that creates "default.wav" in the same directory file_orig.Open("default.wav", CFile::modeRead); int length = file_orig.GetLength(); // <<<<< here is the problem !! pBuffer = (char*)malloc(length); file_orig.Read(pBuffer, length); file_orig.Close(); file_dest.Open( strFile, CFile::modeCreate|CFile:: modeReadWrite); file_dest.Write(pBuffer, file_orig.GetLength()); file_dest.Close(); free(pBuffer); ============== Any solution that works can be valid (without including aditional libraries if possible). I just want to keep it as simple as possible. Thanks in advance! :)