0

I'm trying to save some settings related data on my Windows Forms application using IsolatedStorageSettings. But as soon as I create an instance of that class, I have an error saying that IsolatedStorageSettings does not exists on the namespace. This is my code :

using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows;
using System.IO.IsolatedStorage;

namespace HangedGame
{
public partial class Form1 : Form
{
    string word;
    string foundWord;
    int count;
    private System.IO.IsolatedStorage.IsolatedStorageSettings appSettings =
        IsolatedStorageSettings.ApplicationSettings;
}
}

What is wrong whit it?

user26830
  • 1,059
  • 4
  • 16
  • 25
  • in winform applications you cannot use isolatedstorage, isolated stroage can be use in windows phone or windows metro style applications. You can easily store your data in memory in a winform app, or xml or any sql server – AOZ Nov 16 '13 at 16:37
  • @AOZ I come actually from a Mac development background so I'm not that familiar with c# or winforms. What would be the equivalent of NSUserSettings in c#? – user26830 Nov 16 '13 at 16:50
  • NSUserSettings ~= IsolatedStorage :) in windows phone and metro style apps. But i guess you have to use a xml or database to keep users data. You should search using db (ado.net) or entity framework. It is very simple to use a db in .Net – AOZ Nov 16 '13 at 16:56
  • Try this: http://stackoverflow.com/a/453230/2387977 – Dherik Aug 17 '15 at 10:17

1 Answers1

0

Try this,

Creating a Folder and File under IsolatedStorage

using (IsolatedStorageFile storage = IsolatedStorageFile.GetStore((IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly | IsolatedStorageScope.User), null, null))
{
    storage.CreateDirectory(@"SampleStorageFolder");
    storage.CreateFile(@"SampleStorageFolder\ReadMe.txt");
}

Reading File created under IsolatedStorage

using (IsolatedStorageFile storage = IsolatedStorageFile.GetStore((IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly | IsolatedStorageScope.User), null, null))
{
   using (StreamReader reader = new StreamReader(storage.OpenFile("ReadMe.txt", FileMode.Open)))
    {
       string content = reader.ReadToEnd();
    }
}
Kurubaran
  • 8,696
  • 5
  • 43
  • 65