U r problem can be solver using Serializeand Deserialize concept
see this 1st u should have namespaces
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
then create a class
[Serializable]
class Class1
{
public string name;
public string ID;
public string address;
}
Serializable is a key word we need to use it
then in main program write this code
BinaryFormatter bnf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
Class1 obj = new Class1();
obj.name = "Arun";
obj.ID = "007";
obj.address="Mysore";
bnf.Serialize(ms, obj);
byte[] obj_content = ms.ToArray();
//File.Create("C:\\arun.arv");
//File.WriteAllBytes("C:\\arun.arv", obj_content);
FileStream fs1 = new FileStream("C:\\arun.arv", FileMode.Create);
BinaryWriter write = new BinaryWriter(fs1);
write.Write(obj_content);
write.Close();
fs1.Close();
FileStream fs = new FileStream("C:\\arun.arv",FileMode.Open);
BinaryReader read=new BinaryReader (fs);
byte[] obj_converter = new byte[fs.Length];
read.Read(obj_converter, 0, obj_converter.Length);
MemoryStream ms1 = new MemoryStream(obj_converter);
BinaryFormatter bnf1 = new BinaryFormatter();
ms1.Position = 0;
Class1 obj2 = (Class1)bnf1.Deserialize(ms1);
Console.Write(obj2.name);
Console.Write(obj2.ID);
Console.Write(obj2.address);