c# - 类型或命名空间 'IsolatedStorage' 不存在于命名空间 'System.IO' 中(是否缺少程序集或引用?)

标签 c# storage isolatedstorage

我遇到了独立存储的问题,基本上我正在为 Windows Phone 和 Windows 桌面制作一个应用程序,用于 Windows Phone 中的独立存储,我正在使用以下内容;

System.IO.IsolatedStorage.IsolatedStorageFile userStore = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();

using (var isoFileStream = new System.IO.IsolatedStorage.IsolatedStorageFileStream("students.txt", System.IO.FileMode.Open, userStore))
{
    using (var isoFileReader = new System.IO.StreamReader(isoFileStream))
    {

    }
}

我以为 Windows 桌面是一样的,但显然不是,有没有不同的方法来实现同样的事情?以避免错误!

最佳答案

您可能正在为 Windows 应用商店(Windows 8 及更高版本)开发 .NET 应用程序,而不是普通的 Win Forms 应用程序。您需要使用 Windows.Storage 命名空间。

没有直接的 System.IO.IsolatedStorage 命名空间..

使用Windows.Storage.ApplicationData.Current.LocalData而不是System.IO.IsolatedStorage.IsolatedStorageFile类。

关于c# - 类型或命名空间 'IsolatedStorage' 不存在于命名空间 'System.IO' 中(是否缺少程序集或引用?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22845916/

相关文章:

c# - 在 Windows Phone 8 App 中播放音效

c# - 如何将 DateTime 设置为 ValuesAttribute 进行单元测试?

javascript - FireFox 扩展中的临时存储

c# - isolatedStorageFile.GetLastAccessTime 在 wp7 上崩溃

.net - 使用 NLog 登录到独立存储

android - 跨多个 Android 应用程序保留登录 session

c# - Directory.GetCurrentDirectory() 不再指向 bin 文件夹

c# - 防止访问继承的成员

Android存储字符串数组

java - Android HTC/Sony 外部存储权限被拒绝