Append File Path in the Same Folder as Running VI

Updated Oct 13, 2023

Reported In

Software

  • LabVIEW Full
  • LabVIEW Base

Issue Details

I have a file that will always be installed in the same location as my current VI, but that location might vary from machine to machine. Is there a way to programmatically determine the file path for that file?

Solution

You can use Application Directory.vi and directly build the desired file's path, as can be seen in the following snippet:
Alternatively, you can use Current VI's Path in LabVIEW to return the path of the calling VI. Then, by using Strip Path and Build Path, you can programmatically construct the file path for the other file. Refer to the following steps for creating code to programmatically set a filepath. 
  1. Place Current VI's Path on the block diagram. This function can be found in the Functions palette at Programming»File I/O»File Constants.
     
  2. Place Strip Path and Build Path on the block diagram. Both can be found in the Functions palette at Programming»File I/O.
     
  3. Wire the diagram as shown below.

Additional Information

Strip Path removes one level of hierarchy from the current path. Conversely, Build Path adds one level of hierarchy to the current path.