02-02-2009 04:51 PM
Hi all,
I'm creating an application that will need to save a few small files that need to be accessible by any user that logs into the PC.
Under XP, I can create a folder under C:\Documents and Settings\All Users\Application Data and place my files in there. I know that this folder is accessible by any user that logs into the computer, therefore when they launch my application it will able to read these files. That way, when one user makes changes to the configuration, the next user see those changes.
But under VISTA, the folder C:\ProgramData\Application Data is a 'junction' to a VirtualStore, as explained by this NI article: http://zone.ni.com/devzone/cda/tut/p/id/5538
This means that if I save my work into here, the files will be accessible to the user that creates them, but not anyone else that logs in. Now it strikes me as a basic need to be able to ensure that a configuration file saved by Fred is also loaded when John next logs in and launches the application. Unfortunately, I cannot work out where the 'officially correct' save space is for applications running under Vista.
Where do people recommend saving 'common' files under Vista that are read and write accessible to all ordinary (non-admin) users?
02-03-2009 11:11 AM
Hi Thoric,
I would recommend using the "C:\Users\Public" public directory, you can create an Application Data Folder in there and all users will be able to access it. I have attached a screenshot of this directory for you.
Please let me know how you get on.
Many thanks,
02-04-2009 03:27 AM
Thanks for the advice Ben. Can I ask a further question please:
This is an extract from the Microsoft MSDN library:
Applications running under Windows Vista should use Known Folders as much as possible and always:
Use the Known Folders APIs (SHGetFolderPathEx or SHGetFolderLocationEx) to look up system or standard folders (such as Documents). These directories and settings have predefined Known Folders created for them as part of the Windows SDK.
Define new Known Folders to contain important information, such as application data, user settings, and registry information, and then always look up these folders using the SHGetFolderPathEx or SHGetFolderLocationEx function in the Known Folders API. This allows administrators to control the roaming of your data, preventing unwanted access and allowing data to move about.
If it is necessary to support backward compatibility with earlier releases (such as Microsoft Windows XP), use the older ShGetFolder and CSIDL values.
As recommended, I do not wish to use absolute or hard-coded paths, but using Environment Variables is the only way I know to query the O.S. for configured paths for saving user-common files. For example, the variable %ALLUSERSPROFILE% is what I used to get the two paths discussed in my first message (C:\Documents and Settings\All Users\Application Data on XP and C:\ProgramData\Application Data on VISTA). The variable for the path you have recommended (C:\Users\Public) is %PUBLIC% in VISTA, but this variable does not exist on XP. Therefore, my code will fail if installed on an XP machine.
According to the MSDN information above, I need to use the Known Folders API (SHGetFolderPathEx...) to determine these locations (ShGetFolder under XP). What does this mean exactly? A call to a dll?
02-04-2009 03:54 AM - edited 02-04-2009 03:55 AM
Hi Thoric,
You're absolutely right.
There's a nice implementation of this posted on LAVA (use Windows_Special_Folders.llb).
Hope this helps, Daniel
07-24-2009 05:59 PM
08-24-2009 04:55 AM
There appears to be a nice new vi in LabVIEW 2009 that returns paths to the system folders for saving application and user data from within your codes.
It's called Get System Directory.vi, and can be reviewed here.
08-24-2009 04:59 AM
0 | User Home—Directory that contains the personal files of the current user. This directory is a readable and writable directory accessible to a single user of the system. |
1 | User Desktop—Directory that contains files located on the desktop of the current user. This directory is a readable and writable directory accessible to a single user of the system. |
2 | User Documents—Default directory for saving the documents of the current user. This directory is a readable and writable directory accessible to a single user of the system. |
3 | User Application Data—Directory that contains data for the system applications of the current user. This directory is a readable and writable directory accessible to a single user of the system. |
4 | User Preferences—Directory that contains the preferences for the current user. This directory is a readable and writable directory accessible to a single user of the system. |
5 | User Temporary—Directory that holds temporary files for the current user. This directory is a readable and writable directory accessible to a single user of the system. You cannot change the path to this temporary directory. |
6 | Public Documents—Directory that contains documents accessible to all users of the system. This directory is readable and sometimes writable. |
7 | Public Application Data—Directory that contains data for system applications accessible to all users of the system. This directory is readable and sometimes writable. |
8 | Public Preferences—Directory that contains preferences common to all users of the system. This directory is readable and sometimes writable. |
9 | System Core Libraries—Directory that contains the libraries that come with the operating system. This directory is typically read-only to the standard user of the system. |
10 | System Installed Libraries—Directory that contains libraries a user installs on the system. This directory is typically read-only to the standard user of the system. |
11 | Application Files—Directory that contains files of applications installed on the system. This directory is typically read-only to the standard user of the system. |
12 | Boot Volume Root—Top-level directory used to start the system. This directory is typically read-only to the standard user of the system. |
08-24-2009 05:01 AM
Can you translate these names into the MS equivalent?