LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I replace a file using Write Characters to file.vi

I want to replace a file of strings without being prompted about being asked to relpace it.
0 Kudos
Message 1 of 4
(3,094 Views)
If you don't want to be prompted as to which file, then you will have to wire in the exact file path. On the block diagram, rt-click on the file path input of this VI and select create constant. In the constant path box, enter the path and name of the file (e.g. C:\programs\text.txt).
This VI also gives you the option to append to file or overwrite by wiring a T or F (F for replacing) to its append to file input.

Good luck, Doug
0 Kudos
Message 2 of 4
(3,094 Views)
1) Check if file already exists and delete if yes
2) Save the new one

If you need more security you could also

1) Check if file already exists and rename (eg. change extension to .bak) if yes
2) Save the new one
3) a) no problem in 2): delete the .bak
b) problem in 2): rename .bak to its original name

You will need to use the intermediate and advanced file functions to do that.
0 Kudos
Message 3 of 4
(3,094 Views)
"Use a sequence of "New file", "Write file" and "Close file". "New file" can overwrite the file no matter what (set overwrite=true)."
0 Kudos
Message 4 of 4
(3,094 Views)