From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

close a file opened in windows XP


 Hi guys,

I'm writing data in a text file and I saw if the file is already open in Windows XP the data are not written and I have no error message.

 

So my question is how can I close the file in Windows with Labview ?

And is there a way to check before closing it if the file is open by Windows ?

 

I tried with "close file" and with "close file+.vi" but it's not working. 

 

Thanks 

 

0 Kudos
Message 1 of 5
(2,617 Views)
The Close File function will only work for files that LabVIEW has opened, not for files that have been opened by another application. There is a utility that ships with Windows XP (not sure about other operating systems) called OpenFiles. This normally works to list files that have been opened by network users, but it can be configured to track local files (at a command prompt type "openfiles /local /?").
0 Kudos
Message 2 of 5
(2,602 Views)

Thank you smercurio_fc for you reply, but I didn't succeed to close my file.

If I understand it right  I should look on Microsoft side and not in a function in Labview ?

Like to use the command with the cmd.exe to close it ?

 

Regards 

0 Kudos
Message 3 of 5
(2,568 Views)

Hi remvu,

 

I once had the same problem. I used the openfiles command-line command. The example below works but has some weaknesses (is not fully implemented yet). But it should be a good starting point for you...

 

Cheggers

Sascha
0 Kudos
Message 4 of 5
(2,549 Views)

remvu wrote:

Thank you smercurio_fc for you reply, but I didn't succeed to close my file.

If I understand it right  I should look on Microsoft side and not in a function in Labview ?

Like to use the command with the cmd.exe to close it ?


Yes, it is a command-line program made by Microsoft. The code that cheggers attached is basically how you would use it. As I noted, the utility is designed to track files opened by network users. To track files opened locally you need to run the command with the "/local ON" parameters. You only need to do this once, though a reboot is required. More information can be found on the Microsoft site.

0 Kudos
Message 5 of 5
(2,536 Views)