Example Code

Get / Set Windows Current Working Directory in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This example shows how to get or set Windows current working directory by calling Windows dll.

 

Description

Sometimes when working with LabVIEW you may need to get or set the Windows current working directory, especially when interacting with another application using either files or Active X.

This is a simple VI that can get or set the current working directory.  If a directory path is entered, the example will set the current working directory. If no input is entered, the VI will return the current working directory path.

There is no direct function in LabVIEW allowing to achieve this goal, so this example VI calls a Windows DLL to provide the functionality.

 

Requirements

  • LabVIEW 2012 (or compatible)
  • Windows OS

 

Steps to Implement or Execute Code

  1. If you need to get the current working directory, leave Set Directory control empty and run the VI
  2. If you need to set the current working directory to a desired path, then set Set Directory control properly and run the VI

 

Additional Information or References

VI Block DiagramSet Current Directory LV 2012 NI Verified.png

  

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

 

------
John.P | Certified LabVIEW Architect | NI Alliance Member

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