If I press the start button and search "shell:SavedGames" it brings me right to a folder that seems to exist to contain game saves. There are many other folders that seem to be a default location for some kinds of data that can be found with the shell: command. Is there a standard way to access these folders programmatically?
Asked
Active
Viewed 2,171 times
1 Answers
4
Are you talking about the Special Folders?
Console.WriteLine("GetFolderPath: {0}", Environment.GetFolderPath(Environment.SpecialFolder.System));
Thanks to Cody's comment for this other link:
Downloads folder: not special enough? and also PInvoke SHGetKnownFolderPath which has a list of Guids as well
You'd want to use PInvoke with the GUIDs from
FOLDERID_SavedGames
GUID{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}
Display Name: Saved Games
Folder Type: PERUSER
Default Path: %USERPROFILE%\Saved Games
CSIDL Equivalent: None, new in Windows Vista
Legacy Display Name: Not applicable
Legacy Default PathNot applicable
There is also a (semi old now) Library from Microsoft called Vista Bridge
-
I found that page but it doesn't have "Saved Games" along with many other folders. Here's one list I found: http://www.techradar.com/news/computing/pc/shell-folders-the-best-kept-windows-time-saving-secret-464668 I've been doing more research and it looks like the solution may be closer to "SHGetKnownFolderPath": http://msdn.microsoft.com/en-us/library/bb762188%28VS.85%29.aspx – Joe Jan 24 '12 at 23:43
-
Yeah, "Saved Games" only exists in Vista and newer which is why its probably not in the list I gave you, since it wouldn't return anything for XP machines. This is why Developers probably make so many different Saved Games locations :( – John Jan 24 '12 at 23:51
-
@Joe: See [here](http://stackoverflow.com/questions/3795023/downloads-folder-not-special-enough/3795159#3795159) for instructions on how to get at the new special folders that are not provided by the `Environment.SpecialFolder` enumeration. – Cody Gray - on strike Jan 25 '12 at 04:11
-
@CodyGray that looks like a good work around, though you should probably have it check that it gets a valid path (`String.IsNullOrWhiteSpace(path)`) and if not then return the legacy path as well. The `if (hr == 0)` probably covers that but might not always... better safe than sorry when dealing with IO imho. – John Jan 25 '12 at 06:47