LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Leave File Open But Overwrite Entire Contents with New Text

Solved!
Go to solution

Is this possible to do in LabVIEW?

 

I know I can open file and read from it, then close and then open again --with REPLACE or CREATE to Write new text. But this involves two open procedures.

 

So can I replace content, after opening once to read, and then issue a replace text function?

Anthony

0 Kudos
Message 1 of 4
(1,021 Views)

Actually, I just realized that this can best be done using the ini File system. Ini files can left open to write and update key data via sections and keywords.

 

Anthony

0 Kudos
Message 2 of 4
(1,013 Views)

If you want to "rewrite" the file (which really means doing the equivalent of "Close", "Replace") without doing the Close or Replace, you can use Set File Position to set the File Position to 0 (the beginning of the File) and then Set File Size to 0 (I'm not 100% certain that this step is necessary, not having "done the Experiment, myself, but it seems "safe and logical" to me).  Now anything you write will start from the beginning of the file, and when you close the file, only what you've newly-written will be saved.  Note that I would expect if you choose not to write anything, but do close the file, you will be left with a file of 0 bytes, which is not the same thing as deleting the file (for one, it will be much easier to retrieve the data from a Deleted file, just look in the Deleted Files "waste-basket").

 

Bob Schor

0 Kudos
Message 3 of 4
(981 Views)
Solution
Accepted by rolfk
0 Kudos
Message 4 of 4
(967 Views)