我在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