Hello altogether!
I have a remark to make and a question in the end:
I use TFileStreams to append single AnsiStrings (TMemo->Text) at the end of a file. I am not using RichEdits (my files are in the end about 87k big) as it takes much too much time to append these strings to the Richedit and save it (I need to save it everytime , because I need the rest of the file when I get an exception).
I also used
when I was ready with the file.
Now I wanted to open the praticular file which was opened by the filestream once again after an exception, and I recieved a "cannot open/create" this file. What I did was not deleting the savestream properly in any case. After that was done the error still came up.
So in the next step I did it like this:
THIS IS SUGGESTED LIKE THAT IN THE BCB5 HELP!!!!!!!!!!!!!!!!!!
"use FileClose after You deleted the Stream Object"
And I got intermediate but worse errors as suddenly files were not exisiting which I didn't touch at all !!!!!!!!
(I even got a lot of WinAPI failures a.s.o.)
I risked not to do what is suggested. I interpreted the sentence "The handle of the Stream is freed before the object is deleted" as true and thought than it is natural that the MyStream_>YHAndle maybe points to another (unknown) file...
So I turned around the two lines (at any point in the code where I had it) to the following:
and now I am so happy with it that I wanted to tell You that.
Has anybody similar experiences?
Do You think this is helpful or am I doing a very stupid and dangerous thing here?
Regards
Michael
I have a remark to make and a question in the end:
I use TFileStreams to append single AnsiStrings (TMemo->Text) at the end of a file. I am not using RichEdits (my files are in the end about 87k big) as it takes much too much time to append these strings to the Richedit and save it (I need to save it everytime , because I need the rest of the file when I get an exception).
I also used
Code:
delete mystream;
Now I wanted to open the praticular file which was opened by the filestream once again after an exception, and I recieved a "cannot open/create" this file. What I did was not deleting the savestream properly in any case. After that was done the error still came up.
So in the next step I did it like this:
Code:
TFileStream *MyStream = new TFileStream(AnyFileName, fmCreate);
delete MyStream;
TFileStream *MyStream = new TFileStream(AnyFileName, fmOpenReadWrite);
...
delete MyStream;
FileClose(MyStream->Handle);
THIS IS SUGGESTED LIKE THAT IN THE BCB5 HELP!!!!!!!!!!!!!!!!!!
"use FileClose after You deleted the Stream Object"
And I got intermediate but worse errors as suddenly files were not exisiting which I didn't touch at all !!!!!!!!
(I even got a lot of WinAPI failures a.s.o.)
I risked not to do what is suggested. I interpreted the sentence "The handle of the Stream is freed before the object is deleted" as true and thought than it is natural that the MyStream_>YHAndle maybe points to another (unknown) file...
So I turned around the two lines (at any point in the code where I had it) to the following:
Code:
...
FileClose(MyStream->Handle);
delete MyStream;
and now I am so happy with it that I wanted to tell You that.
Has anybody similar experiences?
Do You think this is helpful or am I doing a very stupid and dangerous thing here?
Regards
Michael