LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I need to access multiple files in a directory on the hard drive and then display them in a dialog box so the user can choose what file he/she wants to open.

What I want to do is have the user enter a file they want to search for (however, the name they enter will only be the first portion of a filename). Then I would like to search for all the files on the hard drive that have the user word in the beginning of their filename. I would like to display a text box that shows all the files with the user word in it and then let the user choose what file they want to open. If anyone could help, I'd really appreciate it.
0 Kudos
Message 1 of 6
(3,172 Views)
Well, i've attached an vi that simply searches for files commencing with a string in "c:". Of course, if you want to set another directory, change the input. If you want to search in all the hard drive, the work is a little bit harder. Instead of only taking file names, you'll have to wire the directory names output and take all directories in the root, then build those directories and wire them again to File search, for example, using a while loop and a shift register. When you finish with one directories subdirs (when dir names is an empty string) start with another one... Instead of doing this, you could use api calls to let windows do all this for you. If you have any questions, just ask... Good luck
0 Kudos
Message 2 of 6
(3,172 Views)
Take a look at this web site http://www.val-tech.com/software/labview/. They have a VI library called 'fill array with directory tree'. This will do the hard part fo you. Once you have an array with all the paths for the hard drive, you can use the list directory VI to list the files. Then you can use the match pattern vi to search the file names for the search string. I'm working on something similar, I'll share when it's done.

Hope this helps,
0 Kudos
Message 3 of 6
(3,172 Views)
If you have a directory list, you don't have to use match pattern, just wire the pattern to list directory vi, you can use * for any string and ? for any character.
0 Kudos
Message 4 of 6
(3,172 Views)
That was the first thing I tried. The problem I had was when you wire the pattern, it applies it to files and directories. So, I used Val-Tech's solution to get a list of all directories on a given drive. I found that using the match pattern solution ran a little bit faster than accessing every path in the list, and required fewer steps to get the output I wanted. I'll take a second look at my implemetation to see if there's something I missed.
0 Kudos
Message 5 of 6
(3,172 Views)
I found the website useful and am using the Vi from there. However, I was wondering if there is a way to hook up a list box attribute node and then a double click attribute node so the user can just click on what path he/she wants. I tried to hook up a list attribute node, but it wouldn't give me this option with the VI. I was wondering if you had any ideas?
0 Kudos
Message 6 of 6
(3,172 Views)