IsolatedStorageSettings缺少程序集

时间:2013-11-16 16:17:57

标签: c# winforms settings

我正在尝试使用IsolatedStorageSettings在我的Windows窗体应用程序中保存一些设置相关数据。但是一旦我创建了该类的实例,我就会发出一个错误,指出名称空间中不存在IsolatedStorageSettings。这是我的代码:

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;
}
}

有什么问题吗?

1 个答案:

答案 0 :(得分:0)

试试这个,

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();
    }
}