Click here to Skip to main content
15,912,400 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Append data in middle of binary file Pin
Christian Graus12-Oct-06 14:10
protectorChristian Graus12-Oct-06 14:10 
GeneralRe: Append data in middle of binary file Pin
samkook12-Oct-06 15:00
samkook12-Oct-06 15:00 
GeneralRe: Append data in middle of binary file Pin
Christian Graus12-Oct-06 15:16
protectorChristian Graus12-Oct-06 15:16 
GeneralRe: Append data in middle of binary file Pin
samkook12-Oct-06 16:06
samkook12-Oct-06 16:06 
GeneralRe: Append data in middle of binary file Pin
Christian Graus12-Oct-06 16:13
protectorChristian Graus12-Oct-06 16:13 
GeneralRe: Append data in middle of binary file Pin
samkook12-Oct-06 16:19
samkook12-Oct-06 16:19 
GeneralRe: Append data in middle of binary file Pin
Christian Graus13-Oct-06 0:59
protectorChristian Graus13-Oct-06 0:59 
GeneralRe: Append data in middle of binary file Pin
David Crow13-Oct-06 3:00
David Crow13-Oct-06 3:00 
samkook wrote:
if( !fVampFile.Open(csFilename, CFile::modeRead | CFile::shareDenyNone | CFile::typeBinary) )


Your code is not wrong, but CFile objects open in binary mode by default.

samkook wrote:
fVampFile.SeekToBegin();


This is redundant as the file pointer is already positioned at the beginning.

samkook wrote:
for (int iCtr = 0; iCtr < 10; iCtr++)
{
fVampFile.Read(cByteBuff,iByteMove);
cByteArray[iCtr] = *cByteBuff;
}


Reading one byte at a time, disk I/O is going to be your enemy here. Try:

int nLength = fVampFile.GetLength();
LPBYTE pBuffer = new BYTE[nLength];
fVampFile.Read(pBuffer, nLength);
fVampFile.Close();
fVampFileSav.Write(pBuffer, nLength);
fVampFileSav.Close();
delete [] pBuffer;
Once you get this working correctly, then you can add the code that inserts the new text;


"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

"Judge not by the eye but by the heart." - Native American Proverb


GeneralRe: Append data in middle of binary file [modified] Pin
samkook13-Oct-06 6:46
samkook13-Oct-06 6:46 
GeneralRe: Append data in middle of binary file Pin
David Crow13-Oct-06 7:16
David Crow13-Oct-06 7:16 
GeneralRe: Append data in middle of binary file Pin
samkook13-Oct-06 7:29
samkook13-Oct-06 7:29 
QuestionCannot add event handlers in VC++ 2005... Pin
Lord Kixdemp12-Oct-06 10:52
Lord Kixdemp12-Oct-06 10:52 
AnswerRe: Cannot add event handlers in VC++ 2005... Pin
prasad_som12-Oct-06 19:00
prasad_som12-Oct-06 19:00 
GeneralRe: Cannot add event handlers in VC++ 2005... Pin
Lord Kixdemp13-Oct-06 10:20
Lord Kixdemp13-Oct-06 10:20 
QuestionDialog problem! Pin
Larsson12-Oct-06 10:24
Larsson12-Oct-06 10:24 
AnswerRe: Dialog problem! Pin
Mark Salsbery12-Oct-06 10:32
Mark Salsbery12-Oct-06 10:32 
AnswerRe: Dialog problem! Pin
David Crow12-Oct-06 10:44
David Crow12-Oct-06 10:44 
GeneralRe: Dialog problem! Pin
Larsson12-Oct-06 11:06
Larsson12-Oct-06 11:06 
GeneralRe: Dialog problem! Pin
Hamid_RT12-Oct-06 19:49
Hamid_RT12-Oct-06 19:49 
AnswerRe: Dialog problem! Pin
amjadamq12-Oct-06 10:46
amjadamq12-Oct-06 10:46 
GeneralRe: Dialog problem! Pin
Larsson12-Oct-06 11:07
Larsson12-Oct-06 11:07 
GeneralRe: Dialog problem! Pin
Larsson12-Oct-06 11:12
Larsson12-Oct-06 11:12 
GeneralRe: Dialog problem! Pin
prasad_som12-Oct-06 19:07
prasad_som12-Oct-06 19:07 
GeneralRe: Dialog problem! Pin
David Crow13-Oct-06 2:46
David Crow13-Oct-06 2:46 
Questionofstream issue in a class Pin
Nick Usechak12-Oct-06 10:17
Nick Usechak12-Oct-06 10:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.