Public Static voidWritecookiestodisk (stringfile, Cookiecontainer Cookiejar) { using(Stream stream =file.create (File)) { Try{Console.Out.Write ("Writing cookies to disk ..."); BinaryFormatter Formatter=NewBinaryFormatter (); Formatter. Serialize (stream, Cookiejar); Console.Out.WriteLine ("Done ."); } Catch(Exception e) {Console.Out.WriteLine ("problem writing cookies to disk:"+E.gettype ()); } } } Public StaticCookiecontainer Readcookiesfromdisk (stringfile) { Try { using(Stream stream =File.Open (File, FileMode.Open)) {Console.Out.Write ("Reading cookies from disk ..."); BinaryFormatter Formatter=NewBinaryFormatter (); Console.Out.WriteLine ("Done ."); return(Cookiecontainer) formatter. Deserialize (stream); } } Catch(Exception e) {Console.Out.WriteLine ("problem reading cookies from disk:"+E.gettype ()); return NewCookiecontainer (); } }
C # writes Cookiecontainer to a local