Example Program Drafts

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple file search

Overview

This example searches whether a particular file exists in the search path.

Description

Use this VI if you want to manually check if a file exists in a specific file path.  The VI gets an array of the files in the directory using List Folder.vi, and then searches that array for the file name.  If the file exists, it returns the full file path of the file and a Boolean true. Otherwise, it returns an empty file path and a Boolean false.

Steps to Implement or Execute Code

  1. Open the version of the example which works with your version of LabVIEW
  2. Enter a path for in the Directory Path control
  3. Enter a file name in the File Name to Search control 
  4. Run this example independently or as a SubVI
  5. See the results on the front

Requirements to Run

Software

LabVIEW 8.6 or higher

Hardware

N/A

Additional Images

Block Diagram

File Search.png

Comments
Trusted Enthusiast Trusted Enthusiast
Trusted Enthusiast

One thing to notice is that this specific solution only works on Windows. due to the usage of the '\' in the append string.

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Active Participant Himanshu_Goyal
Active Participant

Pande,

The function List Folder will give you the folder and file list of directory path, if the file is available in any folder this function will not work and your code will not be able to get and directory path hierarchy. I think you should replace Folder List function with Recursive file list to get access of complete hierarchy and then you can search file in result list.........:-)

Thanks and Regards
Himanshu Goyal | LabVIEW Engineer- Power System Automation
Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
It Only gets BETTER!!!
Trusted Enthusiast Trusted Enthusiast
Trusted Enthusiast

What does this VI do that the LabVIEW function 'Check if file or folder exists' doesn't do?

http://zone.ni.com/images/reference/en-XX/help/371361J-01/check_if_file_or_folder_exists.gif

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Member D*
Member

Yes, use "Check if file or folder exists".  If you really want to search, then the Recursive file list is best, especially when using the filename as the "pattern" input to that .vi.

Contributors