tags:

views:

203

answers:

4

We are making a game which will add a level editor feature soon. We want the user to be able to put levels he's downloaded in a folder and then play it in the game, without any hassle. So, we're looking for a folder that anybody can find, open, write, read, and is multiuser. On Windows Vista / 7, the folder /Users/Public/ look like a great candidate. However, It's not listed in the .net enum System.Environment.SpecialFolder. I have went through them all, and checked what they yield on different Windows versions, and none live up to my requirements.

I did find Environment.SpecialFolder.CommonApplicationData, that kinda works, but that folder is hidden (C:\ProgramData) and I assume most users don't display hidden folders.

As it stands now, it looks like we'll have to settle for the personal documents folder, but we'd really like a multi user folder.

Anyone have any tips?

(Hard coding c:\Users\Public\ is out of the question, it will only work on english systems)

+1  A: 

Could you put a folder in the application's directory, then create a shortcut to it for every user (when they first use the feature) in their home directory? I know it's not quite the "Universal" pre-existing folder you may have wanted, but would this work anyway?

FrustratedWithFormsDesigner
You would need to be an administrator to work with the application's directory
Colin Pickard
+5  A: 

Doug Hennig on finding the path for C:\Users\Public:

There isn’t a CSIDL value for this folder, but the environment variable PUBLIC points to it, so you can use GETENV('PUBLIC') to determine its location. By default, this variable contains C:\Users\Public in Windows Vista. The variable doesn't exist in Windows XP, so your code must handle the case where GETENV('PUBLIC') returns a blank value.

Alternatively, you could use the parent of the folder specified by CSIDL_COMMON_DOCUMENTS, which gives C:\Documents and Settings\All Users\Documents on XP and C:\Users\Public\Documents on Vista.

I think Environment.SpecialFolder.CommonDocuments may be the right place for your files.

Colin Pickard
CommonDocuments sounds awesome, however it's .net 4.0, and I'm using mono 1.2.5 (which is like .net 2.0), so I'll have to make somthing like the above. Thanks.
reallyjoel
A: 

This may help. See this Post:

  1. http://msdn.microsoft.com/en-us/library/bb762584%28VS.85%29.aspx

  2. http://stackoverflow.com/questions/784487/location-of-allusersprofile-folder-in-windows-vista

In Windows Vista or later:

%PUBLIC% C:\Users\Public

In Windows XP:

%ALLUSERSPROFILE%   C:\Documents and Settings\All Users
Ganesh R.
+2  A: 

The following should return C:\Users\Public\Documents\ on Vista/Win7 and C:\Documents and Settings\All Users\Documents for previous OSes.

[System.Runtime.InteropServices.DllImport("shell32.dll")]
static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken,
 uint dwFlags, [Out] StringBuilder pszPath);

public string GetSharedDocsFolder() {
 StringBuilder sb = new StringBuilder();
 int CommonDocumentsFolder = 0x002e;

 SHGetFolderPath(IntPtr.Zero, CommonDocumentsFolder, IntPtr.Zero, 0x0000, sb);
 return sb.ToString();
}
C-Pound Guru
That looks way scary..
reallyjoel