Click here to Skip to main content
12,894,930 members (58,007 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C++ Builder
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.

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TFileStream* fs;
 
  fs = new TFileStream("c:\\test.log", fmCreate);
}
Posted 2-Aug-11 3:47am
JustH762
Updated 2-Aug-11 5:42am
Uwe Keim153.4K
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

    Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.170424.1 | Last Updated 2 Aug 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100