CopyFile problem
-
Hi All, This seems such a simple problem, I am embarrassed to ask for help, but I just can't seem to get the syntax correct for the CopyFile command. My application builds a vector of CStrings containing commands in format Copyfile( "source file", "dest file", FALSE ), using double quotes around the file specifications in case there are embedded spaces. The following is one of the commands:
CopyFile( "C:\Documents and Settings\rfickling\My Documents\Expense Report Form.xls", "Expense Report Form.xls", FALSE );
All of these commands fail with an error code of 123, which indicates invalid call syntax. What is wrong here? Can anyone help me with this dumb little problem? Thanks, Royce -
Hi All, This seems such a simple problem, I am embarrassed to ask for help, but I just can't seem to get the syntax correct for the CopyFile command. My application builds a vector of CStrings containing commands in format Copyfile( "source file", "dest file", FALSE ), using double quotes around the file specifications in case there are embedded spaces. The following is one of the commands:
CopyFile( "C:\Documents and Settings\rfickling\My Documents\Expense Report Form.xls", "Expense Report Form.xls", FALSE );
All of these commands fail with an error code of 123, which indicates invalid call syntax. What is wrong here? Can anyone help me with this dumb little problem? Thanks, Royce -
RoyceF wrote:
CopyFile( "C:\Documents and Settings\rfickling\My Documents\Expense Report Form.xls", "Expense Report Form.xls", FALSE );
Don't you escape slashes?
Yes, in the CString.Format() method call you do:
CString str; str.Format( "C:\\Documents and Settings\\rfickling\\My Documents\\Expense Report Form.xls" );
I am actually formatting these file specs into CString variables so that it looks like the following:strSrc = "C:\Documents and Settings\rfickling\My Documents\Expense Report Form.xls"; strDst = "Expense Report Form.xls"
So the command in C++ syntax is:CopyFile( strSrc, strDst, FALSE );
This should work, but I get a 123 error. -
Hi All, This seems such a simple problem, I am embarrassed to ask for help, but I just can't seem to get the syntax correct for the CopyFile command. My application builds a vector of CStrings containing commands in format Copyfile( "source file", "dest file", FALSE ), using double quotes around the file specifications in case there are embedded spaces. The following is one of the commands:
CopyFile( "C:\Documents and Settings\rfickling\My Documents\Expense Report Form.xls", "Expense Report Form.xls", FALSE );
All of these commands fail with an error code of 123, which indicates invalid call syntax. What is wrong here? Can anyone help me with this dumb little problem? Thanks, RoyceError code 123 is "The filename, directory name, or volume label syntax is incorrect." Does this help narrow it down?
*EDIT* You shouldn't have to add any double quotes because of spaces.
-- modified at 18:10 Wednesday 22nd November, 2006 -
Yes, in the CString.Format() method call you do:
CString str; str.Format( "C:\\Documents and Settings\\rfickling\\My Documents\\Expense Report Form.xls" );
I am actually formatting these file specs into CString variables so that it looks like the following:strSrc = "C:\Documents and Settings\rfickling\My Documents\Expense Report Form.xls"; strDst = "Expense Report Form.xls"
So the command in C++ syntax is:CopyFile( strSrc, strDst, FALSE );
This should work, but I get a 123 error.I think the problem is the target file name. You are giving just a filename, so Windows tries to create the file in the current directory. And what's the current directory? Try giving a targetname with a complete path, if possible. Or make sure the current directory is set to where you want the file to be copied to. SetCurrentDirectory();
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
-
Yes, in the CString.Format() method call you do:
CString str; str.Format( "C:\\Documents and Settings\\rfickling\\My Documents\\Expense Report Form.xls" );
I am actually formatting these file specs into CString variables so that it looks like the following:strSrc = "C:\Documents and Settings\rfickling\My Documents\Expense Report Form.xls"; strDst = "Expense Report Form.xls"
So the command in C++ syntax is:CopyFile( strSrc, strDst, FALSE );
This should work, but I get a 123 error.The following code works fine on my computer (Win2k):
CString strSrc, strDst; strSrc.Format( "C:\\\\Documents and Settings\\\\Carlo\\\\My Documents\\\\Donald Duck.txt" ); strDst.Format( "Donald Duck.txt" ); if ( CopyFile( strSrc, strDst, FALSE )==FALSE) { // some error handling... }
-
Hi All, This seems such a simple problem, I am embarrassed to ask for help, but I just can't seem to get the syntax correct for the CopyFile command. My application builds a vector of CStrings containing commands in format Copyfile( "source file", "dest file", FALSE ), using double quotes around the file specifications in case there are embedded spaces. The following is one of the commands:
CopyFile( "C:\Documents and Settings\rfickling\My Documents\Expense Report Form.xls", "Expense Report Form.xls", FALSE );
All of these commands fail with an error code of 123, which indicates invalid call syntax. What is wrong here? Can anyone help me with this dumb little problem? Thanks, RoyceRoyceF wrote:
CopyFile(
instead of this use ShFileOperation
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you
-
RoyceF wrote:
CopyFile(
instead of this use ShFileOperation
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you