locked
Preferred location for storing configuration data? RRS feed

  • Question

  • Where is the preferred location for storing config data? I plan to store it in XML format, naturally.

    I have read that XBAP apps have access to a fixed amount of storage in (only) a particular location... what is this location, and is this where an XAML app designed for use both standalone and browser use should store this config data?
    Saturday, January 19, 2008 2:35 AM

Answers

  • I think you should be able to use IPersistComponentSettings for that... it can work with ASP.Net, Winforms, WPF.

    http://msdn2.microsoft.com/en-us/library/system.configuration.applicationsettingsbase.aspx
    http://msdn2.microsoft.com/en-us/library/0zszyc6e.aspx
    http://msdn2.microsoft.com/en-us/library/k4s6c3a0.aspx
    http://blogs.msdn.com/rprabhu/articles/433979.aspx

    Saturday, January 19, 2008 12:15 PM
  • You can use isolatedStorage

     

    Code Block

    private void saveRecentFilesList()

    {

    using (IsolatedStorageFile f = IsolatedStorageFile.GetUserStoreForAssembly())

    using (var s = new IsolatedStorageFileStream (isolatedStorageName,FileMode.Create,f))

    using (var writer = new StreamWriter(s))

    {

    for (int i = 0; i < recentFilesIndex; i++)

    writer.WriteLine(recentFiles[i]);

    }

    }

     

     

     

     

    Code Block

    private void getRecentFilesList()

    {

    IsolatedStorageFile f = IsolatedStorageFile.GetUserStoreForAssembly();

    if (f.GetFileNames(isolatedStorageName).Length == 0)

    {

    // File does not exist

    return;

    }

    using (var s = new IsolatedStorageFileStream(isolatedStorageName, FileMode.Open, f))

    using (var reader = new StreamReader(s))

    {

    string line = reader.ReadLine();

    recentFilesIndex =0;

    while(line != null)

    {

    recentFiles[recentFilesIndex] = line;

    recentFilesIndex += 1;

    line = reader.ReadLine();

    }

    }

    }

     

     

     

    Tom

     

    Sunday, January 20, 2008 2:09 AM

All replies

  • I think you should be able to use IPersistComponentSettings for that... it can work with ASP.Net, Winforms, WPF.

    http://msdn2.microsoft.com/en-us/library/system.configuration.applicationsettingsbase.aspx
    http://msdn2.microsoft.com/en-us/library/0zszyc6e.aspx
    http://msdn2.microsoft.com/en-us/library/k4s6c3a0.aspx
    http://blogs.msdn.com/rprabhu/articles/433979.aspx

    Saturday, January 19, 2008 12:15 PM
  • You can use isolatedStorage

     

    Code Block

    private void saveRecentFilesList()

    {

    using (IsolatedStorageFile f = IsolatedStorageFile.GetUserStoreForAssembly())

    using (var s = new IsolatedStorageFileStream (isolatedStorageName,FileMode.Create,f))

    using (var writer = new StreamWriter(s))

    {

    for (int i = 0; i < recentFilesIndex; i++)

    writer.WriteLine(recentFiles[i]);

    }

    }

     

     

     

     

    Code Block

    private void getRecentFilesList()

    {

    IsolatedStorageFile f = IsolatedStorageFile.GetUserStoreForAssembly();

    if (f.GetFileNames(isolatedStorageName).Length == 0)

    {

    // File does not exist

    return;

    }

    using (var s = new IsolatedStorageFileStream(isolatedStorageName, FileMode.Open, f))

    using (var reader = new StreamReader(s))

    {

    string line = reader.ReadLine();

    recentFilesIndex =0;

    while(line != null)

    {

    recentFiles[recentFilesIndex] = line;

    recentFilesIndex += 1;

    line = reader.ReadLine();

    }

    }

    }

     

     

     

    Tom

     

    Sunday, January 20, 2008 2:09 AM
  • I just remembered there's a sample application that shows how to do settings:

    http://blogs.msdn.com/jfoscoding/attachment/765361.ashx

     

    This comes from a larger document:

    http://blogs.msdn.com/jfoscoding/articles/765135.aspx

     

     

    Thursday, February 28, 2008 2:53 AM