Click here to Skip to main content
13,196,946 members (71,845 online)
Click here to Skip to main content
Add your own
alternative version


27 bookmarked
Posted 27 Apr 2002

Application Data Utility Class

, 27 Apr 2002
Rate this:
Please Sign up or sign in to vote.
ApplicationData is a generic utility library class for managing an application's data


This article introduces a class ApplicationData that simplifies an application's data management

According to the "Designed for Windows XP spec v2.3" you should Classify application data into the following categories:

  • Per user, roaming
  • Per user, non-roaming
  • Per computer (non-user specific and non-roaming)"
NOTE: The three categories are named here as: User, LocalUser and Common respectively.

Knowing where to store files and registry settings for each of this categories can be complicated and require repeating code. This utility class tries to simplify this process. Furthermore, the spec requires that application data should be stored under:

[company name]\[product name]\[version]

The required information is extracted from the assembly attributes (e.g. AssemblyCompanyAttribute), therefore it is highly recommended to fill the appropriate attributes (typically in AssemblyInfo.cs) when using this utility.

Example locations:

  • C:\Documents and Settings\All Users\Application Data\My Company\My Product\1.0.840.34747\Sub1\Sub2\My File.txt
  • "HKEY_CURRENT_USER\Software\My Company\My Product\1.0.840.34747\Local\Sub1\Sub1"

Usage Examples:

// Working with files: 
FileInfo file = ApplicationData.LocalUser["Sub1"]["Sub2"].GetFile("file.txt"); 
StreamWriter writer = file.CreateText(); 
writer.WriteLine("This is a test of ApplicationData!"); 
// Working with the registry:
RegistryKey key = ApplicationData.LocalUser["Sub1"]["Sub2"].GetRegistryKey(); 
key.SetValue("Test", "This is a test!");

Classes used in this utility library include:

System.Windows.Forms.Application which has very useful properties such as: Application.LocalUserAppDataPath, Application.CommonAppDataRegistry, etc...

System.WeakReference which is used to store the references for the three static root instances (Common, LocalUser and User). By using the weak references I don't have to recreate the instances each time they are needed and they can be garbage collected if not used. (see ApplicationData.GetAppDataByType() for implementation)

I hope this utility comes in handy. I would appreciate any comments or suggestions you may have!


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Michael Mumcuoglu
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralAbsolute path Pin
Mark E Lawrence19-Aug-08 13:40
memberMark E Lawrence19-Aug-08 13:40 
GeneralThanks! Pin
axelriet20-Nov-05 0:53
memberaxelriet20-Nov-05 0:53 
GeneralIsolatedStorage Pin
Andy Smith28-Apr-02 20:06
memberAndy Smith28-Apr-02 20:06 
GeneralRe: IsolatedStorage Pin
Michael Mumcuoglu30-Apr-02 11:59
memberMichael Mumcuoglu30-Apr-02 11:59 
GeneralRe: IsolatedStorage Pin
John Fairbanks31-Mar-09 7:34
memberJohn Fairbanks31-Mar-09 7:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171019.1 | Last Updated 28 Apr 2002
Article Copyright 2002 by Michael Mumcuoglu
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid