Reputation: 99
as you all know we simply use
Session["kurd"]="";
or
Cahce.Insert(...)
and its save data in memory; its save data without serialize or any thing like that so we can simply save everything
but its not reliable way to save data;
so may you guys say you can save on database or file but in my case it cant be done, because my data its not serializable, and i can only save it in cache , session , viewdata,viewbage ,... because it dos not need to be serialize data first ; and because of not reliability in session , cache ,... i want way that can save data just like cache and session ,... without serialize data
anyone knows how we can do such thing (save data) in disk i mean save data on hard drive just like session did on memory?
update :
the data type is instance of that class in picture that contain httpclient , httpclienthandeler,deviceinfo,...
update :
how wonderful it is that no one knows how can i save data in hard drive just like what session did in memory no question no serialize no bs, just save it very easy
Upvotes: 0
Views: 809
Reputation: 99
i solved this problem HttpClient cant be serialize but i found out that the only thing in HttpClient that we should save in this thread is "CookieContainer" so serlize and deserilze like this
var formatter = new SoapFormatter();
string file = "..\cookies.dat";
//
using (Stream s = File.Create (file))
formatter.Serialize(s, cookies);
//
CookieContainer retrievedCookies = null;
using (Stream s = File.OpenRead (file))
retrievedCookies = (CookieContainer) formatter.Deserialize(s);
so i serialize it and save it and then for new use i create new HttpClient and assign that CookieContainer to HttpClent.CookieContainer
this problem was for Instasharper
Upvotes: 0
Reputation: 81
Programmatically you can use ObjectDumper.
Or, if you are debugging, you can use a Visual Studio extension called Object Exporter
Upvotes: 2