LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

delete file or skip if already open

Solved!
Go to solution

I have a piece of code going back to the LabVIEW 7.1 days that writes an ascii text file out to a server once every 30 minutes.  Each half hour's file is the previously posted file appended with another 30 minutes of data and I iterate a file number, 2, 3, 4, etc so 4 contains 30 more minutes of data than does three and so forth...  As I write each new file I attempt to delete its predesessor such that in an ideal case there would only be one file sitting there at all times...  However, I want folks to be able to open remotely the files on this server any time they wish... In LabVIEW 7.1, if I attempted to delete a file that was already open, it did NOT generate a show stopping error but just went on...  I could then manually later go toss the file here or there that someone would have had open when the delete attempt was made...  

 

But now I'm running in LabVIEW 2011 the same luxury does not exist...  If I try to delete an already open file, the code generates an error and waits...  That's bad as no one will be there to respond..  I've read one other post about looking to see if temp files exist but I'm not sure what exactly to look for as folks might use one of a slew of ascii text reading programs, from Excel to Matlab to WordPad to open these files...  Surely there must be some attribute of a file I can look at that will tell me it's currently open and if so, I can just skip that deletion and move on...  

 

Bottom line is how can I tell that a file on a server is already open via some unknown application on some desktop far away????

 

thanks...  bob...

0 Kudos
Message 1 of 3
(2,599 Views)
Solution
Accepted by topic author paris1_

Most likely you are running into automatic error handling wiich is enabled by default in newer LabVIEW versions (it did not exist in ancient versions). Whenever a function returns an error, but the error out is not wired, it will popup an error message.

 

Make sure you handle the error by not leaving the error out disconnected. (e.g. simply ingore it by wiring to a structure boundary) so it will not pop up an automatic error dialog.

0 Kudos
Message 2 of 3
(2,597 Views)

Thanks a million...  I didn't know that if I wired the error out, such would preclude the delete sub-vi (not editable) from throwing its error..  But I wired it out to a simple "clear error" but I suppose I could have used the Simple Error Handler or whatever and now it no longer throws an error...  Learn new things every day...  That's just what I was seeking...  thanks much... bob..

0 Kudos
Message 3 of 3
(2,583 Views)