Access to System Directories from LabVIEW
Overview
This document is the first proposal for the changes regarding access to system directories that will occur in a future version of LabVIEW. Our goal is to work with the LabVIEW community to provide guidelines on proper usage of system directories. This will provide a general overview of the changes. In the future, we plan to provide many more details.
This proposal originates from a LabVIEW Feature Brainstorming discussion post titled System directory access and LabVIEW directory changes.
These changes will not occur in LabVIEW until 2009 or later.
Also refer to Changes in the LabVIEW Directory for information on other directory-related changes that will occur in a future version of LabVIEW.
Table of Contents
The Problem
"Cross-platform applications... must not use hard-coded paths."
Cross-platform applications with a dispersed directory structure must not use hard-coded paths. We need to account not only for differences between platforms, but differences between versions of the same platform -- for example, differences between Microsoft Windows XP and Microsoft Windows Vista.
We must provide an API to allow users to create applications free of hard-coded system paths that might change between different systems. For example, the Program Files directory differs between XP, Vista32, and Vista64 and the User Documents directories differ between XP and Vista, as shown below.
Example
The user's documents directory on Windows 2000 and XP:
C:\Documents and Settings\<Username>\My Documents\
The user's documents directory on Windows Vista:
C:\Users\<Username>\Documents\
Current System Directory Access
LabVIEW currently provides path constants to a few application and system directories. These include:
- Temporary directory is currently used to save various LabVIEW application files and is not appropriate for most end-user applications
- Default Data directory is a version-independent LabVIEW directory under the user's Documents directory
- Default directory is often not clear on which disk location is associated with the path constant.
These locations are insufficient for most end-users to create applications that use a dispersed directory structure.
The Solution
"LabVIEW will help customers succeed..."
We will introduce a new Get System Directory VI that provides access to key root directories available on all supported platforms. Below, the VI gets the user's home directory. The expanded ring listing of available directory types also is shown.

A directory listed above might not exist, for example, if a user deletes that special directory. The Create Directory input allows the user to create the directory if it does not exist. You also can use this VI to check if the directory exists.
In addition, the Installer Builder will expand its set of special directories to include, for example, Public Documents and Public Application Data.
Example Usage
Below, the Get System Directory VI accesses files that are relative to a special system directory.
Open an application readme file in a browser

Write a log file to the User Application Data directory

Directory Types
The following table lists the proposed Directory Types available in Get System Directory.vi along with the returned paths on the different supported operating systems.
| Directory Type | Directory path returned for each operating system | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| User Home |
|
||||||||
| User Desktop |
|
||||||||
| User Documents |
|
||||||||
| User Application Data |
|
||||||||
| User Preferences |
|
||||||||
| Public Documents |
|
||||||||
| Public Application Data |
|
||||||||
| Public Preferences |
|
||||||||
| System Libraries |
|
||||||||
| Application Files |
|
||||||||
| Volume Root |
|
||||||||
| Temp |
|
Comments on API Decisions
Names:
Since directory naming conventions vary across platforms, we chose platform-neutral terminology.
Paths:
LabVIEW will utilize the following system paths.
Windows: operating system API determines path, specifically SHGetFolderPath().
Mac OS: operating system API determines path, specifically FSFindFolder().
Linux: Users rely on conventions for directory creations and use (no standard API).
Set of directories:
We provide access to the standard directories that are most useful to LabVIEW applications and do not cause cross-platform problems.
Installer Builder
The Get System Directory VI allows you to access system directories at runtime. In addition, the Installer Builder will expand its set of special directories to include, for example, Public Documents and Public Application Data, thus allowing you access to the same set of directories at install time.
Forum Questions
"LabVIEW wants your feedback..."
- Do you agree with that we have the right set of directories in the Directory Type list? If not, what should be added or removed? [forum link]
- Do you agree with our cross-platform names (User Documents, Public Preferences, etc.) and their associated disk locations? [forum link]
- Besides Get System Directory VI and more entries in Installer Builder, what other features are needed to create applications that disperse files to appropriate special operating system directories? [forum link]
- Other comments/questions about the Get System Directory VI? [forum link]
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
