Solved

Saving a TFileStream

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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