Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
swdev:dotnet:data_and_configuration_folders [2011/04/01 09:44] smayr [Managed Code] |
swdev:dotnet:data_and_configuration_folders [2011/04/01 16:08] (current) smayr [InnoSetup] |
||
---|---|---|---|
Line 88: | Line 88: | ||
===== Native Code ===== | ===== Native Code ===== | ||
+ | |||
The best API to use if you are targeting Vista and beyond is the new SHGetKnownFolderPath. This function replaces SHGetFolderPath and has the following advantages. | The best API to use if you are targeting Vista and beyond is the new SHGetKnownFolderPath. This function replaces SHGetFolderPath and has the following advantages. | ||
Line 97: | Line 98: | ||
NULL, & | NULL, & | ||
{ | { | ||
- | printf(" | + | printf(" |
} | } | ||
Line 105: | Line 106: | ||
NULL, & | NULL, & | ||
{ | { | ||
- | printf(" | + | printf(" |
} | } | ||
</ | </ | ||
Line 111: | Line 112: | ||
The output on Windows 7 is: | The output on Windows 7 is: | ||
< | < | ||
- | SHGetKnownFolderPath FOLDERID_RoamingAppData =C: | + | SHGetKnownFolderPath FOLDERID_RoamingAppData = C: |
- | SHGetKnownFolderPath FOLDERID_Documents | + | SHGetKnownFolderPath FOLDERID_Documents |
</ | </ | ||
Line 143: | Line 144: | ||
===== Native Code ===== | ===== Native Code ===== | ||
+ | |||
If you are still targeting XP, you’ll need to use the legacy API SHGetFolderPath that uses CSIDL’s. | If you are still targeting XP, you’ll need to use the legacy API SHGetFolderPath that uses CSIDL’s. | ||
Line 154: | Line 156: | ||
| | ||
{ | { | ||
- | printf(" | + | printf(" |
} | } | ||
Line 164: | Line 166: | ||
| | ||
{ | { | ||
- | printf(" | + | printf(" |
} | } | ||
</ | </ | ||
Line 170: | Line 172: | ||
The output on Windows 7 is: | The output on Windows 7 is: | ||
< | < | ||
- | SHGetFolderPath CSIDL_APPDATA | + | SHGetFolderPath CSIDL_APPDATA |
- | SHGetFolderPath CSIDL_MYDOCUMENTS =\\zaw\Mydocs\patricka\My Documents | + | SHGetFolderPath CSIDL_MYDOCUMENTS = \\zaw\Mydocs\patricka\My Documents |
</ | </ | ||
The output on XP is: | The output on XP is: | ||
< | < | ||
- | SHGetFolderPath CSIDL_APPDATA | + | SHGetFolderPath CSIDL_APPDATA |
- | SHGetFolderPath CSIDL_MYDOCUMENTS =C: | + | SHGetFolderPath CSIDL_MYDOCUMENTS = C: |
</ | </ | ||
Line 196: | Line 198: | ||
Think about the type of files your application is writing. | Think about the type of files your application is writing. | ||
+ | == Best Practices == | ||
+ | |||
+ | Store only application files in '' | ||
+ | Store share application data in '' | ||
+ | Store user data in '' | ||
+ | |||
+ | ==== Coding in C# ==== | ||
+ | Use '' | ||
+ | <code csharp> | ||
+ | string userAppData | ||
+ | string commonAppData = Envrionment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); | ||
+ | </ | ||
+ | |||
+ | ==== InnoSetup ==== | ||
+ | Set proper permissions for shared '' | ||
+ | <code inno> | ||
+ | [Dirs] | ||
+ | Name: {commonappdata}\Acme\MyApp; | ||
+ | </ | ||
== Resources == | == Resources == | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// |