LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with deleting a file previously open for writing

Hi
In one of my applications, I am deleting a file which was previously opened for writing. While running the source code, it is working fine. But when running the executable, the file still exist there (and there is no error message prompted).
If I open the file only for reading, there is no problem deleting it while running the executable.
 
Any idea what could be going wrong here ? After each opening, I do call the file close as well.
 
Thanks in advance.
0 Kudos
Message 1 of 3
(2,524 Views)


 


@Deepu wrote:
Hi
In one of my applications, I am deleting a file which was previously opened for writing. While running the source code, it is working fine. But when running the executable, the file still exist there (and there is no error message prompted).
If I open the file only for reading, there is no problem deleting it while running the executable.
 
Any idea what could be going wrong here ? After each opening, I do call the file close as well.
 
Thanks in advance.



Deepu,

You ve mentioned that while running the source code it is working fine, meaning that the error dialog pops-up while the file is getting deleted after being kept open physically. There is a big difference between a file being opened by LV to write to it or read from it and us keep opening the file physically to read or write. So, please dont get confused between them.

But while running the EXE, it is getting deleted sans any error msg, means eithrer it should be a non-readonly file or a file without a proper file extension. Otherwise, you should ve connected the error-out wire to some node like to the seq frame or something like that.But my last assumption gets eliminated because you ve already mentioned that the error msg pops out when run from the source code.

Do you write the file without any extension? That may be a possibility for Windows to allow a file to be deleted albiet its being kept opened physically.

One last question. Do you want to delete the file or you DONT want it to be so ? Smiley Wink

- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 2 of 3
(2,510 Views)
Thanks for your reply Partha.
I think my message was not clear enough. Let me explain one more time:
 
When the user runs the software for the first time in a system, a file is created by the software and something is written into it. The file is closed after that. When the user enters a software key, the software verifies it and if valid, deletes the created file.
The file is created, opened and closed only by the software.
The user is allowed to enter the key during the first run or on any subsequent run. This works fine as long as I am running the source code.
However when I built the exe and installed on a system, I noticed that the file is not deleted if the key is entered during the first run. If I close the software, start again and entered the key, the file is deleted properly.
So here the difference is:
1. On the first run, the file is created and written some value.
2. On the second or subsequent run, the file is opened for read only.
Any time if the file is open, after read or write it is closed using the "Close File+.vi" from "file.llb".
 
Is there a chance like LabVIEW does not release the control even after closing the file, if the file is opened in write mode ?
The software is written in LV7.0
 
_Deepu.
0 Kudos
Message 3 of 3
(2,485 Views)