Click here to Skip to main content
Rate this: bad
good
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 4:47am
Edited 2-Aug-11 6:42am
Uwe Keim132.1K
Comments
Maximilien at 2-Aug-11 15:40pm
   
what is fmCreate ?
Chuck O'Toole at 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
0 DamithSL 300
1 Zoltán Zörgő 170
2 OriginalGriff 150
3 Sergey Alexandrovich Kryukov 120
4 Maciej Los 115
0 OriginalGriff 7,740
1 DamithSL 5,769
2 Sergey Alexandrovich Kryukov 5,424
3 Maciej Los 5,076
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 2 Aug 2011
Copyright © CodeProject, 1999-2014
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