Solved

Saving a TFileStream

Posted on 2004-08-09
3
379 Views
Last Modified: 2010-04-05
I am using a TFileStream, is there anyway to save the stream apart from uing free. I am opening the stream
    oStream := TFileStream.Create( sFilename, fmShareExclusive or fmOpenReadWrite );

I keep the file open so no one else can open it, the user needs to be able to click save at any time and I need to save all changes up to that point.

0
Comment
Question by:julianpointer
[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

Expert Comment

by:wolsen
ID: 11759440
you could just create another file stream and copy that stream to it.
0
 
LVL 5

Expert Comment

by:Lukasz Lach
ID: 11760336
or you can use LockFile() function to protect the file from being written (or read) by other process...
0
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 125 total points
ID: 11760903
Well, when you write to the stream, it should be written to disk immediately. That's basic behaviour for filestreams... By using free, you also force the buffers to be written.  But in general these buffers are handled by Windows, not by the stream itself. You could try:

  FlushFileBuffers(oStream.Handle);

just in case...
0

Featured Post

Independent Software Vendors: 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

729 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