kiranreddys.com
Kiran's personal website
Blog    Forums   Sitemap   Social    Phone
 
     

 
Knowledgebase
 
Home
Knowledge base home, and site home.
Categories
List of all Knowledge base categories.
Glossary
An alphabetical list of technical terms.
Contact Me
Contact me for knowledge base questions
My Blog
My articles, white papers, ideas and thoughts.
 

 
 


Serializing and De-Serializing the Objects.

Date Added July 23, 2010 | Print | Bookmark

//Required the following using directives
//using System;
//using System.IO;
//using System.Runtime.Serialization.Formatters.Binary;

//Serializing and De-Serializing the Objects:

private void SerializeObject(Object object, string fileName){

 Stream binaryStream = File.Open(fileName, FileMode.Create, FileAccess.ReadWrite);
 try{
      BinaryFormatter binaryFormatter = new BinaryFormatter();
      binaryFormatter.Serialize(binaryStream, object);
 }finally{
      binaryStream.Close();
 }

}

private Object DeSerialiseObject(string fileName){

 BinaryFormatter binaryFormatter = new BinaryFormatter();
 Stream reader = File.Open(fileName, FileMode.Open, FileAccess.Read);
 try{
     Object object = binaryFormatter.Deserialize(reader);
 }finally{
      reader.Close();
 }               

 return object;
}

Was this article helpful?

Yes No

Category: C#.NET- I/O

Last updated on July 29, 2010 with 3226 views

0 User Comments

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment

CAPTCHA Image
Security code

 



Home | About Me | Products | Support | Contact | Knowledgebase | Forums | Blog | Site map | Site Search | Subscribe | Links | Social | News

Travel | Guest Book | All Pages | History | Site Calendar | Recipes | Ex-Rates | UK Stuff | Downloads | Telugu Stuff | Tell a Friend | Feedback

Bookmark and Share
www.kiranreddys.com
Terms of Use
Site contents Copyright © 2008-2009 Kiran Reddy. All rights reserved.