LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Listing directory (list directory.vi) performance

I have a problem when using list directory.vi module to get list of files over the network. Directory contains shortcuts in to destination workstation's hard disk. Directory listing takes about 30 seconds to go and there are no other files, only those few shortcuts. When polling directory where there are no shortcuts, it works fine.
I need to poll these directories because we are checking incoming new files.
There is no difference in processing time when using pattern.
Any ideas are welcome.
0 Kudos
Message 1 of 5
(3,342 Views)
Hi,

For checking new files in directory WinAPI functions can be used. Waiting for notification will be in any case better than polling.

See some info on msdn site:

Obtaining Directory Change Notifications
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/obtaining_directory_change_notifications.asp

ReadDirectoryChangesW
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/readdirectorychangesw.asp

FindFirstChangeNotification
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/findfirstchangenotification.asp
0 Kudos
Message 2 of 5
(3,342 Views)
Hi Hannu,

The List Directory VI is slow primarily because it tries to resolve any shortcuts in the directory and make sure that they are valid. If there are several shortcuts, this operation will definitely take some time, especially if some of the shortcuts are broken. This issue has been documented and NI's R&D department is aware of the problem.

The List Directory VI does have better performance in LabVIEW 7.1 as well as on a computer using a NTFS file system format.

The previous post by Audrey Dmitriev suggests making calls to the Windows API functions. This is another workaround and you can use the LabVIEW Call Library Node VI to call a Windows DLL. The following article may be helpful for you:
KnowledgeBase 1GRAN2U0. Where Can I Get Help Calling Windows API Functions from LabVIEW?

Note that there is an excellent Developer Zone example program that is linked off that page as well.

Good luck!

Kileen C.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 5
(3,342 Views)
Many thanks for both of these answers 🙂

This notification makes sense and it is good also in my other projects. I tested this in local and network drives and it works fine but I found note from MS that there is possibility to lost notification from network drive.
Anyway, I have to read that directory now when I get this notification from changed or new file in destination directory. Is there any other way to get directory listing because of these shortcuts in destination directory ?
0 Kudos
Message 4 of 5
(3,342 Views)
Hi Hannu,

You can try mapping the network machine to your computer (right-click on My Computer and choose Map Network Drive). This might reduce the access time to the network a bit and it's something you might want to experiment with. I've included an example program that will allow you to explore machine file hierarchy once a computer has been mapped to your computer.

Kileen C.
Applications Engineer
National Instruments
0 Kudos
Message 5 of 5
(3,342 Views)