LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Do I have to close file once I write to it in order to save it?

Hi,
I am writing to file every 5 sec and I don't want to lose any data upon unexpected shutdown of PC or error.
I use openfile and writeline functions. (CVI Functions)
1. I noticed that my program saves my data to file even if I don't close file. (I verified this by opening file while program is still open)does cvi closes file when when I exit from program.
2. what is the best practise to do this kind of task?
My program sequence is as follows. a. open file. b. write to file (WriteLine)every 5 sec until I write 5000 lines and then close this file and open new file and repeat.

Thanks for your help.
Sheetal
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 1 of 2
(2,953 Views)
The file buffers are periodically flushed to disk anyway, but you don't know when Windows is going to do this.

The CVI library doesn't have an explicit function for flushing file buffers and I can't see any documentation that tells you if the flushing is forced internally. So maybe your best bet is to close the file after each write, to force the buffers to be flushed. Or you could move to the ANSI C FILE handling functions, which include an explicit fflush() facility.

Also, you should always try to use a journalling file system like NTFS rather than FAT or FAT32, as they have the capability to recover more data in the event of power loss or crash.

--
Martin.
--
Martin
Certified CVI Developer
0 Kudos
Message 2 of 2
(2,953 Views)