https://github.com/ogunerkutay/windows-app-data-storage-guidelines
https://github.com/ogunerkutay/windows-app-data-storage-guidelines
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ogunerkutay/windows-app-data-storage-guidelines
- Owner: ogunerkutay
- Created: 2025-09-18T11:53:38.000Z (19 days ago)
- Default Branch: main
- Last Pushed: 2025-09-18T12:05:55.000Z (19 days ago)
- Last Synced: 2025-09-18T13:45:58.031Z (19 days ago)
- Size: 61.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# đź“‚ Windows App Data Storage Guidelines
A quick reference for where to store **application files** on Windows.
Following these conventions keeps apps clean, avoids permission issues, and aligns with industry standards.---
## đź—‚ Key Directories
| Folder | Usage | Access |
|--------|-------|--------|
| **AppData\Roaming** | User-specific **settings, configs, small data** that should move with the user across domain PCs. | `%APPDATA%` → `C:\Users\\AppData\Roaming` |
| **AppData\Local** | User-specific **non-roaming data**, like caches, logs, temp DBs. Stays on that PC. | `%LOCALAPPDATA%` → `C:\Users\\AppData\Local` |
| **AppData\Local\Temp** | Short-lived, disposable files. OS may auto-delete. | `%TEMP%` → `C:\Users\\AppData\Local\Temp` |
| **ProgramData** | Machine-wide, non-user-specific data. Shared configs, DBs, license info. | `%PROGRAMDATA%` → `C:\ProgramData` |
| **Documents** | Files visible to the user (documents, projects). | `%USERPROFILE%\Documents` |
| **Registry** | Small settings, app state, licensing keys. | `HKCU\Software\` (per-user)
`HKLM\Software\` (machine-wide) |---
## 🔑 Rules of Thumb
- **Settings / Configs → Roaming**
- **Cache / Logs / Big Files → Local**
- **Shared Data → ProgramData**
- **User Documents → Documents**
- **Temporary Files → Temp**
- **Small Key-Values → Registry**❌ Never write to `Program Files` at runtime (requires admin & breaks UAC rules).
---
📌 Example App File Layout

---
## đź› Accessing Paths in .NET (C#)
```csharp
// User-specific folders
string roaming = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string local = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string temp = Path.GetTempPath();// Example usage
string settingsPath = Path.Combine(roaming, "MyApp", "settings.json");
string cacheFolder = Path.Combine(local, "MyApp", "cache");
✅ Always use Environment.SpecialFolder — don’t hardcode paths.✅ Best Practices
Respect Windows conventions (don’t confuse roaming/local).Store only what’s necessary (avoid bloat in roaming).
Use registry only for small configs, not data storage.
Clean up temp files after use.
Use installer/project setup to create default directories.
đź“– Quick mental model:
Roaming = “Settings I want everywhere”
Local = “Stuff that belongs only to this PC”
Temp = “Safe to throw away”
ProgramData = “Shared across users”
Registry = “Tiny key/value pairs”