A relative path describes the location of a file or directory relative to an arbitrary location in the file system. An absolute path describes the location of a file or directory starting from the top level of the file system. Relative paths are also referred to as symbolic paths. Use relative paths in VIs to avoid having to rework the paths when you build an application or run the VI on a different computer.
Complete the following steps to create a relative path.
- Place the Default Directory constant on the block diagram.
- Place the Build Path function on the block diagram.
- Wire the Default Directory constant to the base path input of the Build Path function.
- Right-click the name or relative path input of the Build Path function and select Create»Constant.
- Use the Labeling tool to double-click the name or relative path constant and enter the filename or relative path to the file. Use the syntax appropriate for your operating system.
- (Windows) A path consists of the drive name, followed by a colon, followed by backslash-separated directory names, followed by the filename. An example is C:\DATADIR\TEST1 for a file named TEST1 in the directory DATADIR on the C drive. You also can drag a path from Windows Explorer and place it in the path constant.
- (Mac OS) A path consists of the drive name, followed by colon-separated folder names, followed by the filename. An example is HardDrive:DataFolder:Test1 for a file named Test1 in the folder DataFolder on the volume named HardDrive.
- (Linux) A path consists of slash-separated directory names followed by the filename. An example is /usr/datadirectory/test1 for a file named test1 in the directory /usr/datadirectory.