我在windows phone應用程序中編寫了此代碼以便從xml文件讀取和寫入數據,並且工作正常。 ,所以我想在Windows 8.1中的應用程序使用它,但它沒有工作,我如何將其轉換爲與Windows 8.1將IsolatedStorageFileStream從Windows phone 8.1轉換爲Windows 8.1
public void Read(string strXMLFile)
{
IsolatedStorageFile isfData = IsolatedStorageFile.GetUserStoreForApplication();
XDocument doc = null;
IsolatedStorageFileStream isfStream = null;
if (isfData.FileExists(strXMLFile))
{
isfStream = new IsolatedStorageFileStream(strXMLFile, FileMode.Open, isfData);
doc = XDocument.Load(isfStream);
isfStream.Close();
}
else
{
doc = XDocument.Load(strXMLFile);
isfStream = new IsolatedStorageFileStream(strXMLFile, FileMode.CreateNew, isfData);
doc.Save(isfStream);
isfStream.Close();
}
var vData = from s in doc.Descendants("Row") select new ColData(s);
}
public void Write(string strXMLFile)
{
XElement xml = new XElement("Tabel",
from p in this
select p.Information);
IsolatedStorageFileStream isfStream = new IsolatedStorageFileStream(strXMLFile, FileMode.Open, IsolatedStorageFile.GetUserStoreForApplication());
xml.Save(isfStream);
isfStream.Close();
}
你究竟是什麼意思,但「不起作用」? – 2014-11-09 13:25:23
我的意思是這個代碼適用於Windows Phone 8.1應用程序,但不適用於Windows 8.1應用程序或Windows RT應用程序 – masalahi 2014-11-09 13:32:45
是的,但是定義什麼不起作用。拋出異常?代碼掛起?究竟是什麼? – 2014-11-09 13:34:26