2014-04-03 99 views
2

我遇到了單獨存儲的問題,基本上我爲兩個windows phone和Windows桌面爲我的孤立存儲在Windows手機我使用以下;命名空間'System.IO'中不存在類型或命名空間'IsolatedStorage'(您是否缺少程序集或引用?)

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桌面,但顯然它不是,是否有不同的方式來實現相同的事情?爲了避免錯誤!

+0

我剛剛創建了一個新的WinForms應用程序(文件 - >新建 - >項目 - > Windows窗體應用程序),它就在那裏。我甚至嘗試切換到一個較舊的框架和客戶端配置文件,它仍然被認可。根據文檔它在mscorlib中定義,所以它不應該是一個參考問題。 –

+0

@CraigW嗯我不確定那是因爲那是出現的問題。你有什麼想法? – user3263978

+0

我唯一的想法是不支持它的框架版本,但我一直回到2.0,每次都編譯得很好。我甚至把我的引用縮減到System,System.Drawing和System.Windows.Forms,並且它仍然被編譯。我的建議是嘗試創建一個新的分支項目,並將第一行代碼放入其中。如果這對你有用,那麼在原始項目中存在一些配置問題,你需要做一些試驗和錯誤來弄清楚它是什麼。 –

回答

3

你可能在做一個.NET應用程序Windows商店(Windows 8及以上版本),而不是一個正常的Win Forms應用程序。您需要使用Windows.Storage命名空間。

沒有直接System.IO.IsolatedStorage命名空間..

使用Windows.Storage.ApplicationData.Current.LocalData代替System.IO.IsolatedStorage.IsolatedStorageFile類。

+0

我已經在使用Windows.Storage和Windows.Storage.Pickers – user3263978

+0

msdn確認[here](http://msdn.microsoft.com/zh-cn/library/3ak841sy (v = vs.110).aspx)@raja表示:'獨立存儲不適用於Windows應用商店應用。而應使用Windows Runtime API中包含的Windows.Storage命名空間中的應用程序數據類來存儲本地數據和文件。有關更多信息,請參閱Windows開發人員中心中的應用程序數據 –

相關問題