Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I am trying to create a basic file in Builder c++, however I get a 'Invalid Handle exception c00000008'.

This is the only code I have, behind a button.

C#
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TFileStream* fs;

  fs = new TFileStream("c:\\test.log", fmCreate);
}
Posted
Updated 2-Aug-11 5:42am
Comments
Maximilien 2-Aug-11 15:40pm    
what is fmCreate ?
Chuck O'Toole 2-Aug-11 21:01pm    
a constant meaning "create a new file". The documentation on TFileStream is on many sites, here is one: http://www.functionx.com/bcb/fileprocessing/vclfilestream.htm

1 solution

Are you sure the exception occurs on the single line of code you show? This can not be "the only code" you have.

fs, the pointer to the stream is a local variable and hence discarded when this function exits. So, what do you intend to do with the file you just created since you do not return the handle to the file. "Invalid Handle" is a clue that somebody else wants to touch that file.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900