Topic: Creation of a file over the existing

At outswapping of the data here thus...

FileStream: = TMemoryStream. Create;
StringStream: = TStringStream. Create (");
FileStream. LoadFromStream (StringStream);
FileStream. SaveToF .ile (' C:\1.txt ');

... The file is not re-recorded.
How to make, that it was deleted and formed anew.
To me it is critical that other program should take FileAge (), and there always one and too.
If it manually to delete, forms with normal date, last and actual.
To win I can not in any way.


Re: Creation of a file over the existing

1. Explicitly to delete and create .
2. And it is even better not to use FileAge. To search for last modification date.


Re: Creation of a file over the existing

The risky approach
1) you delete a file
2) you start to create a new file
3) here  in the program or in the computer - and the new file forms half only
The old file already is not present, new still is not present - normally?
Here it is necessary flip-flop to do, if the place on a disk suffices, as archivers for example
> Other program should take FileAge ();
1) you delete a file
2) you start to create a new file c new age
3) you have time to write down for example 25 % of a file...
4) here other program wakes up and starts it to read, reads percent 30 and is disconnected
5) you stop to write down a file - but everything that you wrote down after 30 % anybody already will be never read
In general, the buffer is one business, and a sign of readiness of the buffer - another! They should be held separately.
IMHO the correct variant
1) you get a folder of type C:\Exchange
2) the writing program writes there files 000000.txt, 000001.txt, 0000002.txt etc.
3) thus she writes them as 000000. $$$ while completely all data does not suppose on a disk and does not drop . Only then renames $$$ in txt
4) any file never corresponds, generally!
5) the reading program subscribes at Windows for messages about folder C:\Exchange
6) when Windows speaks "the folder changed" - looks at the list *.txt, whether appeared there earlier
7) after successful reading (n).txt reading  deletes (n-1).txt, (n-2).txt etc.
Thus you in a folder just in case always have a previous file
And if debugging is required - you generally will disconnect 7th step and at you ALL data for all period of operation will collect