LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems re-naming an existing file and moving it elsewhere

Okay, here's my latest little puzzle. In my code, I save data files under the name of the serial number that the operator types in. If, later on, someone tries to create a new file with the same serial number as an existing file, the program grabs the existing file, appends the date and time onto that file name, and then moves it to a file called "backup". This lets the most recent file be saved under the serial number, and any older files will be saved as well, along with the date and time the file was moved to the backup file.

Problem - sometimes it works, sometimes it doesn't. It seems to work if I turn LabView off then back on. But if I create a file, stop, clear everything out (in my program), and try to recreate that file, it doesn't rename and move the existing file. I get "error 8 - file sharing problem".

It sounds like it's not closing out the existing file properly, but the same keystroke that wipes out data so you can enter in new data also closes out the file. At least it's supposed to!

Here's the section of code that renames and moves the existing files. Anybody see anything?
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 1 of 5
(2,370 Views)
Here's the error that pops up in the Move command:

Error 8 occurred at Move in HVAC run-in program lab version - C.vi

Possible reason(s):

LabVIEW: File permission error.
---
NI-488: DMA hardware error detected.
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 2 of 5
(2,362 Views)
I seem to get errors because the destination file name has illegal characters. If I remove the "|" and substitute another "-" everything seems to work just fine.

See attached quick modification. (Also make sure that all folders exist and that you have write permission.)
0 Kudos
Message 3 of 5
(2,363 Views)
Added note: Always use the error cluster of the file info and not the file size. Checking for file size=0 would cause problems if (maybe due to some bug!) the file exists but has zero size. You should also use a path constant for "C:\LabView data" and not a plain string. This keeps it platform independent.
0 Kudos
Message 4 of 5
(2,357 Views)
You could be on to something there with the file size. The problem seems to occur when a file is created but no data was added because the test sequence never began because the operator realized there was something wrong with the test conditions, and then the operator tried to re-create the file and start from scratch. I'll try your little fix and see!
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 5 of 5
(2,355 Views)