LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Check if file opened tales to long?

By using the open file VI from the io pallete, to check if a file is already opened (and then colosing the file if no error, and if error 5, file is already opened) it takes like 2seg to check about 20files (100ms\file). Is this normal? Im reading self expanding CSV files (when one file gets full next one starts) beeing writen by another program and I must know wich files are beeing writen. Thers no direct communication between LabVIEW and the program writing the files.
0 Kudos
Message 1 of 15
(4,023 Views)

Are these files on the network or on a local hard disk?  Being on a network share would explain it, I think.

 

If you're doing this with a FOR loop, perhaps you could add parallelization to it to speed it up if that's the main concern.

0 Kudos
Message 2 of 15
(4,019 Views)
I think I tryed both network and local. Anyhow speed difference was not significant (need to check again to be sure tho.). I'll try parallelization then. Thank you. How much ms should take to check if a file is opened? O_O I thought it would take like us...
0 Kudos
Message 3 of 15
(4,003 Views)

I suspect lots of factors could go into why this is taking so long.  Windows user privlages, UAC, firewall, antivirus, and other OS calls could lead to this taking longer than expected.  I'd almost suggest you look at the last mod date of the file to get an understanding if the file is still being written to, I suspect his call will return much faster.  You can also look into other ways of getting file access from .Net or DLL calls.  I remember once being able to get a list of the files an application had access to.  This might be another option for you.

0 Kudos
Message 4 of 15
(3,993 Views)

Example. While the file is not opened upper loop takes no time to open/close the file. If the file is opened by the lower loop, now takes 100ms to check that is opened... Cant this be faster?

 

PD: Sellect a directory with a txt file. Andf watch the timer with a probe (forgot to put the indicator).

0 Kudos
Message 5 of 15
(3,961 Views)

My wild guess is that this is an OS timeout thing.

0 Kudos
Message 6 of 15
(3,941 Views)

I did a test on my machine out of curiosity.  100ms seemed like a long time to just open / close a file.  For me it took about 40 microseconds / file.  If my code below looks similar to what you were doing, you may have smoething else going on.  Even an older computer shouldn't see THAT big of a difference.

 

Check if open.png

 

check time.PNG

0 Kudos
Message 7 of 15
(3,916 Views)

But where your files opened by other process? That seems to be the problem for me xD when they r not opened is no delay. Mby write only is the thing idk... And I have i7 processor so... idk what is happening.

0 Kudos
Message 8 of 15
(3,907 Views)

@BowenM wrote:

I did a test on my machine out of curiosity.  100ms seemed like a long time to just open / close a file.

 


The way I understand the problem, the 100ms delay occurs if we try to open a file that has already been opened elsewhere.

0 Kudos
Message 9 of 15
(3,898 Views)

Yes, I tryed out again like in the picture posted. The paralel loop speeds up things x8. With the files closes I take 20us/file. With opened files it takes 0.013seg/file (wich is due tu the x8 speed of the parallel loop, removing paralelism makes it go back to 100ms) wich again seems like a timeout in order to give the actual file opened error. cos thers no way the same open operation takes infintly longer to check that indded the file is beeing used.

0 Kudos
Message 10 of 15
(3,889 Views)