LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to force overwrite when writing to text file

Hi, all.  I'm trying to design a user interface for modifying configuration files.  The user is supposed to be able to open the file, make changes, and then press Commit, and the program *should* completely overwrite the file with the new data.  Instead, it is appending all of the new data to the end of the existing file.  I've attached the saving VI I've got, and any help would be appreciated.  I've tried several combinations, but with no luck so far:
 
1. open first, with "replace or create", then write, then close
2. open first, with "replace or create", with "write only," then write, then close
3. don't open first, just write to text file
4. open first, with "replace or create", then set file position, mode "start", offset 0, then write, then close.
 
None of these have worked for me.  Is this a glitch with LabVIEW, or is there some combination I missed?  I've read the examples, browsed the Internet for advice, but have come up with nothing.
 
Thanks in advance,
Greg
0 Kudos
Message 1 of 6
(4,559 Views)

Greg:

Your vi did not attach

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 2 of 6
(4,554 Views)
It is not a matter how you open the file, but how you write to the file.
 
Most likely, you have an input set to "append" or you set the write position to the end of the file.
 
What file I/O functions are you using?
0 Kudos
Message 3 of 6
(4,547 Views)

My bad on the file not attaching.  Let's try this again.

 

Yes, I realize it's not so much how I open the file but how I write to it, but I was under the impression that the "open/create/replace" vi was the one that dictated creating a new file, opening a file with read/write/both access, and overwriting files.  It does not appear to be working.  Hopefully the VI will go through this time.

 

Regards,

Greg

0 Kudos
Message 4 of 6
(4,545 Views)
The VI you attached is overwriting the file just fine for me.

Are you sure your progrm is not appending the data then writing the whole file, making it appear that you appended to the file?

Message Edited by Matthew Kelton on 10-19-2007 11:17 AM

0 Kudos
Message 5 of 6
(4,543 Views)
Matthew, you're absolutely right.  I've been so focused on getting the save to not overwrite that I hadn't looked into that.
 
Thanks!
Greg
0 Kudos
Message 6 of 6
(4,525 Views)