1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

CopyFile Function

Discussion in 'MFC' started by eblackmo, Nov 30, 2007.

  1. eblackmo

    eblackmo New Member

    Joined:
    Nov 30, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    master of disaster
    Home Page:
    Hi all

    I have the following code

    Code:
    )
    string line = (*aIt), line1, path;
    					bool res;
    
    					string::size_type i;
    					
    					i = line.find_last_of('\\');
    					line1 = line.substr(0, i);
    					
    					i = line1.find_last_of('\\');
    					line = line1.substr(i + 1, (line.length() - i));
    					
    					path = file + "\\" + line;
    					
    					res = CopyFile((LPCTSTR)line1.c_str(), (LPCTSTR)path.c_str(), ifExists); 
    					cout << "\n" << GetLastError() << endl;
    					
    					
    				}
    			}//else
    The problem is the call to CopyFile fails GetLastError outputs 2 after having a look at winerror.h I think it is a ERROR_FILE_NOT_FOUND error. I assume that refers to the file to be copied. I don't know if I'm calling the function correctly. Any suggestions...please.
     

Share This Page