LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Error 5 : File is open

Solved!
Go to solution

I am having a problem with my VI. I want to create a file every minute and write at a high resolution for that minute. Then after the minute is done and im writing to another file, delete the file I just wrote to. I can create files just fine, but when it is time to delete a file, it gives me "Error 5 : File is open" I have read that there is a refernce open and thats why it doesnt work, but from what I can tell, Im closing all the references.

 

I have a Win 7 computer, and using the C-DAQ to aquire the data, and everything else works fine except the delete fucntion. I have attached my vi for you to look at and would appreciate any help in this matter.

 

Thank you

0 Kudos
Message 1 of 12
(3,943 Views)

Your logic is very disorganized, but why do you have a separate state for deleting the old file (why do you have states?). When you go to create a new file, simply close and delete the old one first. And when you are deleting the old one why do you check to see if it exists first?

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 12
(3,933 Views)

Mike,

 

I was using states because it seemed earier to use. It works for what I wnat except the delete function. Closing and deleting the file before creating a new one doesnt seem to fix the issue. And I eventually want to include logic that allows whether to keep the file or not. I just want to get around the error so I can complete the program.

 

I was trying something different with the check to see if the file exist first. When it throws the error, it sends all files to the labview data file, instead of file in the control

0 Kudos
Message 3 of 12
(3,924 Views)
Your code to too complex for what it is doing. You also should get away from using the express VIs.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 12
(3,917 Views)

First of all, there is no point in creating your DAQmx task just to get 1 sample and then kill it.  Do the DAQmx setup and the task start before your loop.  Stop and clear the task after the loop.  You can the read inside the loop all day long (use the 1 Channel N Samples setup though to get all of your data).

 

I highly recommend you get rid of the Write To Measurement File Express VI.  I think that is keeping your file open and therefore not allowing you to delete it.  Instead, learn to use the TDMS File VIs.  Instead of keeping your path in the shift register, keep the file reference.  When it is time to delete the file, you can close it and you will be given the path of the file you just closed.  Deletion is simple from there.

 

What I would probably do in this situation is keep a buffer of the data and only save the waveforms when desired, instead of saving and deleting.  It'll be a lot easier on your harddrive.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 12
(3,913 Views)

Cross,

 

I know about the DAQ-mx issue with killing it, but for whatever reason that is the only way i am able to get it to run like i want. I want to know how I would go about selecting which reference to close. Especially if i use a shift register?

 

0 Kudos
Message 6 of 12
(3,891 Views)

adamharden25 wrote: I want to know how I would go about selecting which reference to close. Especially if i use a shift register?

 


If you open up the TDMS file using the TDMS VIs, you will have a TDMS File reference.  That is the reference I am referring to.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 12
(3,881 Views)

i understand that, and i have the vi using the TDMS file VIs. But how do I select the right file reference if the shift registers just holds the last file reference value?

0 Kudos
Message 8 of 12
(3,867 Views)

You should only have the one file reference.  When you open the file, you put the reference into the shift register.  For all of the other cases, wire the reference straight through to keep the reference in the shift register.

 

Or are you opening multiple files without closing them?  You shouldn't be.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 12
(3,853 Views)

Yes, im creating a new file every minute. thus the file reference will be different for each one. This program will run for several months and we want to see the high resolution data if certain criteria happens. So thats why i want to create a file and write to it and if there is nothing wrong with the system within that minute the previous file is deleted. Also, you mentioned you would buffer the data, that would work as well, but Im unclear how to implement this.

0 Kudos
Message 10 of 12
(3,837 Views)