Heres a slightly modified version of code I was using in an App i wrote awhile back.
I'd probably go with Philip Nicoletti's recommendation here thoCode:// Open Handle to the two files HANDLE hFileOne = CreateFileA( "FileOne.txt", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); HANDLE hFileTwo = CreateFileA( "FileTwo.txt", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); // Error check if ( hFileOne == INVALID_HANDLE_VALUE || hFileTwo == INVALID_HANDLE_VALUE ) return 0; // Get File size int iSizeOne = GetFileSize( hFileOne, NULL ); // Read FileOne char* strBuffer = new char[ iSizeOne ]; DWORD dwBytesRead = NULL; DWORD dwBytesWritten = NULL; if ( !ReadFile( hFileOne, strBuffer, iSizeOne, &dwBytesRead, NULL ) ) return 0; // Set position to end of file for appending. SetFilePointer( hFileTwo, 0, 0, FILE_END ); // Write to FileTwo if ( !WriteFile( hFileTwo, strBuffer, dwBytesRead, &dwBytesWritten, NULL ) ) return 0; // Cleanup CloseHandle( hFileOne ); CloseHandle( hFileTwo ); delete strBuffer;




Reply With Quote