A1METALHEAD
Programmer
hello! i just have a quick question: why would it come up with a
"cant onpen file because it is being used by another process" exeption? i have some code (much to0 big to post here) that makes one filestream (set to 'index.dat'), then one binaryreader from that stream. the reader reads index.dat and looks for a number (the number is how many names is in index.dat) then it loops thru that many times, and each loop grabs a stirng from index.dat and opens 'members\ + the string it grabed + .dat' adn creates another filestream, and another reader off that stream. here is a code snippit from where im getting the error:
Thanks!
~metalhead
"cant onpen file because it is being used by another process" exeption? i have some code (much to0 big to post here) that makes one filestream (set to 'index.dat'), then one binaryreader from that stream. the reader reads index.dat and looks for a number (the number is how many names is in index.dat) then it loops thru that many times, and each loop grabs a stirng from index.dat and opens 'members\ + the string it grabed + .dat' adn creates another filestream, and another reader off that stream. here is a code snippit from where im getting the error:
Code:
BinaryWriter* br = new BinaryWriter( fs );
br->BaseStream->Seek( 0 , SeekOrigin::Begin );
br->Write( memberInfo->Count );
for( int i = 0; i < memberInfo->Count; i++ )
{
infoParams* temp = dynamic_cast<infoParams*>(memberInfo->Item[i]);
br->Write( temp->name );
String* msg = new String("");
msg = msg->Insert( msg->Length , home );
msg = msg->Insert( msg->Length , "Members\\" );
msg = msg->Insert( msg->Length , temp->name );
msg = msg->Insert( msg->Length , ".dat" );
FileStream* fs2;
try
{
fs2 = new FileStream( msg , FileMode::OpenOrCreate , FileAccess::ReadWrite );
}
catch( DirectoryNotFoundException* e )
{
MessageBox::Show( e->ToString() );
return;
}
BinaryWriter* br2 = new BinaryWriter( fs2 );
br2->BaseStream->Seek( 0 , SeekOrigin::Begin );
br2->Write( temp->rank );
br2->Write( temp->nickname );
br2->Write( temp->task );
br2->Write( temp->e_mail );
br2->Write( temp->finished );
br2->Write( temp->failed );
if( temp->active )
br2->Write( S"act" );
else
br2->Write( S"ina" );
}
~metalhead