
Problem with CFile::Close
I am having a problem closing my files
It is probably that i don't know the commands correctly
i am using CFile
and the command
ftsFile.Close();
and it likes that but whenever i run the program it crashes after
MessageBox("got this far2"); this message which is at the very end
and if OnOK(); is included it crashes after the window is closed
the code is below and what it does is
open two files one read one write, moves past the header info
then reads two hex bytes, flips them, then writes to the new file in
text
and closes
If any body sees the problem that would be great
Thanks Todd
unsigned int swap1,swap2;
unsigned int data1[1],data3;
char* ftsFileName = "f:\\1.fts";
char* bldFileName = "f:\\1.bld";
char* todd;
CFile ftsFile, bldFile;
if ( !ftsFile.Open(ftsFileName, CFile::modeRead), NULL)
{
MessageBox("File Doesn't Exist"); //check out open::Cfile for error
stuff
}
else
{
MessageBox("got this far1");
bldFile.Open(bldFileName, CFile::modeCreate | CFile::modeWrite);
ftsFile.Seek(2880L, CFile::begin);
for (int count1=0;count1<=519;count1++)
{
for (int count2=0;count2<=782;count2++)
{
ftsFile.Read(data1,2);
data3=*data1;
swap1=data3/0x100;
if (swap1==0x0a)
{swap1=0x0b;}
swap2=(unsigned int)fmod(data3,((data3/0x100)*0x100))*0x100;
if (swap2==0x0a)
{swap2=0x0b;}
//fprintf(streamout,"%u ",storage[0][count2]);
_ui64toa(swap1+swap2, todd, 16);
//todd=storage[count2];
bldFile.Write(todd,sizeof(todd));
}
bldFile.Write("\n",sizeof("\n"));
}
//ftsFile.Close();
//bldFile.Close();
//myFile.Close(); /should close but doesn't work
}
MessageBox("got this far2");
OnOK();
Quote:
}