I am facing a very strange problem saving files. Find attached a quick example showing the issue.
The first time I hit "save" and choose a name for the file (numbers.txt, for example), everything works great and the file is created with my data. Nevertheless, if I save the file numbers.txt the first time and then I click on "save" again and choose the same name for the file and click YES after "The file already exists. Do you want to replace it?", the file numbers.txt is replaced, but it gets empty!!!! If I click on "save" again and choose another name (results.txt, for example), the file results.txt is created properly. If I try to replace the file results.txt I will get the same error with an empty file again.
I think that the issue has something to do with "trying to write SAME DATA TWICE in a file", even choosing to "replace" the file. If you stop running the VI, start again, and try to save replacing a file that already exists, the file will not get empty.
Solved! Go to Solution.
I can save the same file several times - and it always has the same content after saving/replacing... (using your VI in LV2009)
After you are done writing to the file, you should finish the whole operation with closing the file. Also, your original code writes the same set of random nubers to the file all the time. If you place the random nuber generation code inside your while loop, it will run every time you press the save button and it will generate a new set of random numbers. Please see the attached snippet for an example.
If you have any further questions, please feel free to ask!
You are right about "closing the file" after operation. How could I miss that??? Thanks!
This VI was just an example and saving the same set of data over and over again is not a problem.