Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 6 Jahren, 2 Monaten
Letzter Beitrag:
vor 6 Jahren, 2 Monaten
Beteiligte Autoren:
Michael, Jimbo, Carlo Hermus

How to "empty" a text file before writing on it.

Startbeitrag von Michael am 12.09.2011 03:56

Hi:

I 'm working on an text editor, so I'm using fCreate,fOpen,fRead, fWrite and fClose to handle the file.

The only problem I have is when in the editor I delete part of the text, so when I want to update the file with the new text, I'm using fWrite but this overwrite only part of the existing text in the file (assuming the new text size is smaller than the already existing on the file...). As a result, the updated file always presents some garbage at the end.
I 'm thinking on creating a file every time I'm updating it, but I 'm wondering if there is a way to "emtpy" the file before writing the new text?

Thanks for the support
Michael

Antworten:

Michael,

Did you also tried fsavetext?



von Carlo Hermus - am 12.09.2011 06:32

Hi,

fOpen(..)
fRead(..)
fClose(..)

fCreate(..)
fWrite(..)
fClose(..)

Regards,
Guenter



von Jimbo - am 12.09.2011 06:42
Quote
Carlo Hermus
Michael,
Did you also tried fsavetext?
Cheers,
Carlo


Excellent!
Guenter


von Jimbo - am 12.09.2011 06:45
Hi Guys:

Thanks for taking the time.

Although fsavetext( ) seems to be a good solution, it has the same efect of using fCreate( ) (instead of fOpen( ) ) and fWrite( ), because if the file already exists, it is deleted and then re-created.

However, I discovered creating a file every time I update it, is not a problem because it only updates the Modified date, since the Created date still the same (which was my primary concern).

Again, thanks for the responses.
Regards;
Michael


von Michael - am 13.09.2011 03:55
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.