-
September 1st, 2005, 02:40 PM
#1
filestream/binarywriter issue
Hello,
I convert a binary file format to another one. The files here are huge ~90 Mb
so I am reading, converting and writting by small peaces (~60000 value at a time).
When running my application (SDI application (one form), no graphics just buttons and text) after reading, converting and writting several peaces, the window becomes white (all button and text disappear) and come back once the reading conversion and writting task is done... I have a progress bar included in the loop too that disappears.
I tried a this->invalidate() in my loop but the form still dissapear after few rounds like if there was a memory leaking issue in the code.
This problem occur only with my writting procedure not with the reading one:
Because I am new to the .NET framework. I am wondering if I used the filestream and binarywriter correctly?.. any idea? I tried flushing within the loops but it did not help.
lDataLenght may reach size of 20,000 values with m_EGData.Nb=3
.....
FileStream* fileEG = new FileStream(strFileName,FileMode::Append);
BinaryWriter* binEG=new BinaryWriter(fileEG);
for (int i=0; i< lDataLenght; i++)
{
for(int j = 0; j < m_EGData.Nb; j++)
{
buffer=(short) (m_EGData[i+4*j]);
binEG->Write(buffer);
}
}
binEG->Close();
fileEG->Close();
....
Thanks,
JP
-
September 8th, 2005, 05:19 AM
#2
Re: filestream/binarywriter issue
You could try placing this in the loop to yeild to other parts of your application.
Code:
Application::DoEvents();
Or run it on a seperate thread.
Code:
ThreadStart* thrdStart = new ThreadStart( this, ConvertFileFunction );
Thread* thrd = new Thread( thrdStart );
thrd->IsBackground = true;
thrd->Priority = ThreadPriority::Normal;
thrd->Start( );
void ConvertFileFunction( void ) {
while( /* Something */ ) {
// PROCESS FILE CHUNK
Thread::Sleep( 10 );
}
}
Last edited by Jinto; September 8th, 2005 at 05:22 AM.
"Lose it? It means go crazy...nuts...insane...bonzo...no longer in possession of one's faculties...3 fries short of a happy meal...WACKO!!!"
-
September 8th, 2005, 02:06 PM
#3
Re: filestream/binarywriter issue
Hello Jinto,
The Application:oEvents option works very well. Thanks for your helpful response.
JP
-
April 15th, 2013, 03:42 AM
#4
Re: filestream/binarywriter issue
I've another problem on filestream/binarywriter.
FileStream ^ fHdl =
gcnew FileStream("test.txt", FileMode::Create);
BinaryWriter ^ bw =
gcnew BinaryWriter(fHdl);
bw->Write(L"testing");
bw->Close();
fHdl->Close();
output in the file is
.testing
. is 0x07 in hex
how to get rid of the dot?
-
April 15th, 2013, 07:53 AM
#5
Re: filestream/binarywriter issue
The BinaryWriter writes objects to the file in a representation that allows to later reconstruct them as they were using a BinaryReader. The 0x07 is the length prefix that announces the count of characters following (see http://msdn.microsoft.com/en-us/libr...v=vs.100).aspx). Try using a StreamWriter instead.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
April 15th, 2013, 09:36 PM
#6
Re: filestream/binarywriter issue
Thanks...also got found out from google...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|