LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Check if File or Folder exists - hangs if network resource is not available

Hi,

I am experiencing a rather annoying problem. My application usually run on network connected windows(10 or 7) computers. On startup I read several network paths from an INI-file, and use "Check if File of Folder Exists.vi" to verify the validity of the path. When computers running the software are connected to our network there are no issues. However, when a computer is offline, the "Check if File or Folder Exists.vi" does not seem to ever want to terminate. Apparantly there is no, or at least a way to generous, timeout on this process.

I tried the OpenG version, "File Exists.vi", and it also have similar issues, although it eventually terminated(10-20 minutes).

From previous issues with this VI I understand that the problem really is with the windows API, but could not NI add some reasonable timeout to the VI to ensure some predictable behaviour?

0 Kudos
Message 1 of 9
(5,024 Views)

This sounds like a Good Idea for LabVIEW.  If you look on the first page of the LabVIEW Forum, you'll see other Forums, including the Idea Exchange.  Put this post on the LabVIEW Ideas, suggesting that they add an optional TimeOut input and TimedOut? Output on the Check if File or Folder Exists function (there's room on the Connector Panel for these connections).  If enough people Kudo your suggestion, it can get incorporated into a later version of LabVIEW.

 

Bob Schor

0 Kudos
Message 2 of 9
(4,995 Views)

Hi Bob,

 

I thoght about posting on Good Ideas. However, I believe this is some sort of bug and posted it here to see if there were any response and if someone had a workaround. I'll post something in Good Ideas too 🙂

 

By the way, I added code to identify and extract the network computer name from the path, ran that into the "String to IP"-function and added a test to not run the "Check if File or Folder Exists.vi" if the IP returned as "0". This solved my problem!

Message 3 of 9
(4,992 Views)

Hi Treigstad,

I appreciate this is an old thread.  If your subscribed and still active, can you tell me how to identify and extract the network computer name from the path.  I have the same problem, I would like to avoid my application hanging when a shared drive is unavailable.

Brian

0 Kudos
Message 4 of 9
(4,803 Views)

If you are using Windows, you can use Windows' API instead.

Take a look this thread:

http://forums.ni.com/t5/LabVIEW/quot-File-or-Folder-exists-quot-VI-returns-TRUE-if-the-path-is/m-p/4...

 

 

George Zou
0 Kudos
Message 5 of 9
(4,791 Views)

sounds interesting, is it easy to use WindowsAPI from LabVIEW?  I'm not seeing many examples on the LV forums.

0 Kudos
Message 6 of 9
(4,783 Views)

For examples, take a look this page:

http://www.ni.com/example/29935/en/

 

George Zou
0 Kudos
Message 7 of 9
(4,777 Views)

Hi bmann200,

 

This is what I did:

Check IP - then path.PNG

Basically I strip the computer name from the string converted path and then validate it using the String to IP.vi.

Message 8 of 9
(4,753 Views)

Many thanks Treigstad, that works, problem solved, I can see if the Network PC is available or not.

 

When I read \\PCname\folder\folder\file from file, the LV "string to path" function converts it to C:\PCname\folder\folder\file because the file read removes a backslash from the start of the string.  I'm now having to write a VI that determines if the path if a drive letter or backslash, and add a backslash back in if it's the later.

0 Kudos
Message 9 of 9
(4,724 Views)