Solved

TFileStream "append" mode?

Posted on 2002-04-22
3
2,929 Views
Last Modified: 2012-06-21
Hi...
  In my app I've created a disk file with TFileStream in "create" mode. I wish to close this FileStream, then re-open it later in my app and append more data to it. How do I do that? I don't see an "append" mode for TFileStream.

Thanks
  Shawn
0
Comment
Question by:aztec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
Kalroth earned 50 total points
ID: 6961132
I hope this answers your problem.

-- CODE SNIPPIT --

var
  myFile : String;
  yourFile : TFileStream;

begin
  myFile := 'asillyfilename.txt';
  if FileExists(myFile) then begin
    yourFile := TFileStream.Create(myFile,fmOpenReadWrite);
    yourFile.Seek(0,soFromEnd);
  end else begin
    yourFile := TFileStream.Create(myFile,fmCreate);  
  end;

 .. code here ..

end;

-- CODE SNIPPIT --
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6972857
This one would have the same effect:

  with TFileStream.Create('anothersillyfilename.txt', fmOpenReadWrite) do
    try
      Seek(0, soFromEnd);
      .. code here ..
    finally Free end;

If the file does not exist, it is automatically created. So no need to check for the existance of the file.

Regards, Madshi.
0
 

Author Comment

by:aztec
ID: 6975354
thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question