using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
store.CreateDirectory("Dir1");
IsolatedStorageFileStream file = store.CreateFile("Hello.xml");
file.Close();
using (StreamWriter sw = new StreamWriter(store.OpenFile("Hello.xml", FileMode.Open, FileAccess.Write)))
{
sw.WriteLine("
sw.WriteLine("
sw.WriteLine("
}
using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("Hello.xml", FileMode.Open, isoStore))
{
XDocument doc1 = XDocument.Load(isoStream);
TextBox1.Text = doc1.ToString();
}
}
}
In the above code Isolated storage stores are represented by the IsolatedStorageFile object. There's a static method of this object that you can use to obtain the store for the current Application. The IsolatedStorageFile object implements a CreateDirectory method that you can use to create directories called Dir1. Then using the StreamWriter the xml file is create and the xml is added to the “Hello.xml” now we store the xml in the isolated storage.
To retrieve the stored xml file from the isolated storage we are using the IsolatedStorageFileStream. IsolatedStorageFileStream class has several overloaded constructors, in that we are pass in the xml filename, file mode as open, and IsolatedStorageFile object that represents the store where this file will be located.
We are loading the XDocument object and assign the value to the Textbox.
To Get more Check the Below link
http://msdn.microsoft.com/en-us/library/3ak841sy(VS.80).aspx
http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.aspx
http://msdn.microsoft.com/en-us/library/8dzkff1s(VS.80).aspx
http://msdn.microsoft.com/en-us/library/bdts8hk0(VS.80).aspx
http://msdn.microsoft.com/en-us/library/k3352a4t(VS.80).aspx
No comments:
Post a Comment