Solved

Saving a TFileStream

Posted on 2004-08-09
3
374 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
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now