Example Code

File Dialog Using .NET to Select Any File Path

Code and Documents

Attachment

Download All

Overview
This example VI provides a workaround for the File Dialog VI in LabVIEW which cannot select read-only files if the VI is configured for "New or Existing" files.

 


Description
The File Dialog VI in LabVIEW cannot select read-only files if the VI is configured for "New or Existing" files. This example VI provides a workaround for this issue. It opens a customized Windows OpenFileDialog, allows the user to select any existing file (including read-only files) or enter the path of a file they wish to create, then returns the file path of the selected or created file. This VI is designed to be used as a subVI.

NOTE: This VI's Execution property has been changed so that its Preferred Execution System is "user interface." This is to give the ShowDialog method access to the proper thread type.

 


Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Download the attached folder to your computer
  2. Place the VI "Any Path 2012 NIVerified" on a block diagram as a subVI
  3. Wire the error in and error out nodes appropriately, then create an indicator for the "Selected File" output
  4. Run the program
  5. Select any file or enter a new file name, and the "Selected File" output will give you the path

 

Additional Information or References
VI Snippet

 Block Diagram.png

 

 **This document has been updated to meet the current required format for the NI Code Exchange.**

 

Daniel Hays | Test Software Business Manager

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.