C# 隔离存储设置缺少组件

C# 隔离存储设置缺少组件,c#,winforms,settings,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;

我正在尝试使用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;
}
}
有什么不对吗?

试试这个

在IsolatedStorage下创建文件夹和文件

using (IsolatedStorageFile storage = IsolatedStorageFile.GetStore((IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly | IsolatedStorageScope.User), null, null))
{
    storage.CreateDirectory(@"SampleStorageFolder");
    storage.CreateFile(@"SampleStorageFolder\ReadMe.txt");
}
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();
    }
}
读取在IsolatedStorage下创建的文件

using (IsolatedStorageFile storage = IsolatedStorageFile.GetStore((IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly | IsolatedStorageScope.User), null, null))
{
    storage.CreateDirectory(@"SampleStorageFolder");
    storage.CreateFile(@"SampleStorageFolder\ReadMe.txt");
}
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();
    }
}

在winform应用程序中,您不能使用隔离存储,隔离存储可以在windows phone或windows metro样式的应用程序中使用。您可以轻松地将数据存储在winform应用程序、xml或任何sql中的内存中server@AOZ我实际上来自Mac开发背景,所以我对c#或winforms不太熟悉。在windows phone和metro风格的应用程序中,c#中的NSUserSettings的等效值是什么?NSUserSettings~=IsolatedStorage:)。但我想您必须使用xml或数据库来保存用户数据。您应该使用db(ado.net)或实体框架进行搜索。在以下情况下使用db非常简单: