Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Serialize CookieContainer in wp7 applications?
    primarykey
    data
    text
    <p>I tried to Serialize cookie to save it and Deserialize at next time I start my application.But the result of Deserialize is empty.What's wrong?</p> <pre><code>void SaveCookie() { var appStorage = IsolatedStorageFile.GetUserStoreForApplication(); if (this.checkBox_save_passowrd.IsChecked == true) { CookieContainer cc = SEC_Services.Httprequest.cookie; string fileName = "usercookie.xml"; using (var file = appStorage.OpenFile(fileName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write)) { using (var writer = new StreamWriter(file)) { System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(CookieContainer)); xs.Serialize(writer, cc); writer.Close(); } } } else { if (appStorage.FileExists("usercookie.xml")) { appStorage.DeleteFile("usercookie.xml"); } } } void ReadCookie() { var appStorage = IsolatedStorageFile.GetUserStoreForApplication(); if (appStorage.FileExists("usercookie.xml")) { using (System.IO.StreamReader reader = new StreamReader(appStorage.OpenFile("usercookie.xml", FileMode.Open))) { System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(CookieContainer)); CookieContainer obj = (CookieContainer)xs.Deserialize(reader); reader.Close(); SEC_Services.Httprequest.cookie = obj; if (obj.Count != 0) { NavigationService.Navigate(new Uri("/PanoramaPage.xaml", UriKind.Relative)); } } } } </code></pre> <p>I also found this simple <a href="https://stackoverflow.com/questions/1777203/c-writing-a-cookiecontainer-to-disk-and-loading-back-in-for-use">C#: Writing a CookieContainer to Disk and Loading Back In For Use</a> shows that CookieContainer could be Serialize.But there is no <code>SoapFormatter</code> in wp7 library</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload