LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

After write TDMS file, I close the storage ref (file), then I delete the file in program, error occured:File already open. How to solve it?

I want to delete channel groups in TDMS file, but the delete storage VI doesn't work, so I need to copy the needed datas to another file, and then delete the orignal file. The error occured  when I deleted the orignal file, the prompt was: File already open. But I examined my program and I had used the colse storage VI to close the storage ref(file), the ref closed was equal to the ref open. How to solve it?
 
Thanks for your reply!
0 Kudos
Message 1 of 7
(4,271 Views)
The file connections are refcounted, so it might be that you still have an open connection. I can't really tell, since the subVI you use to open the files is not attached. You can check for that by stopping the VI and then deleting the file. Stopping the VI will close any open references in the Storage VIs. If it works after that, you likely have an open connection that needs to be closed.

I also recommend that you don't open and close the files every time your for loop executes.

Looking at your block diagram, I think that using the TDM Streaming API would make your task a lot easier to program and also more efficient at runtime. Regardless of that, using the Storage VIs is a perfectly valid solution.

Herbert
Message 2 of 7
(4,250 Views)
Thanks for your suggestion. I browsed the TDM Stream API, and I found it can smiplify my program as you said.
0 Kudos
Message 3 of 7
(4,226 Views)
The program had been edit using the TDM Stream API, and I can achieve my attention. the edited was also listed.
 
But I also want to know where the error was in the first program. I think the logic of the program was right, but it didn't run.
 
0 Kudos
Message 4 of 7
(4,214 Views)
Could it be that the "file already open" error resulted from the data finder? I had this behaviour at some time that deleting a TDM file directly after creating it didn't work because the data finder was still trying to index it. Waiting for the indexing to finish solved the problem.
 
Regards,
 
Stefan
Message 5 of 7
(4,209 Views)

Another option instead of waiting, is to perform modifications to the file in a directory that is not being indexed by the datafinder.  I have found this to be the most reliable way of performing TDM/TDMS operations.

Jim West

Message 6 of 7
(4,202 Views)

That's right - I can only confirm that. Another problem which can occur if you create a TDM(S) file in a directory included in the index is that the data finder is not able to index the file while it's locked for writing. Data finder before Diadem 10.1 (I think) doesn't retry to index a file once failed during indexing. So you can end up with a set of files not in the index even if they are inside an indexed directory. The only way to reindex them is to move them out and back into the directory.

So, the best way I learned is to create the files in a "safe" place and then move them into an indexed folder, as Jim suggested.

Regards,

Stefan

0 Kudos
Message 7 of 7
(4,178 Views)