static void SaveHashtableFile(Hashtable ht,string path){ BinaryFormatter bfw = new BinaryFormatter(); FileStream file = File.OpenWrite(path); StreamWriter ws = new StreamWriter(file); bfw.Serialize(ws.BaseStream, ht);
file.Close();
}
Open the save Hashtable file
static Hashtable OpenHashtableFile(string path) { FileStream filer = File.OpenRead(path); StreamReader readMap = new StreamReader(filer); BinaryFormatter bf = new BinaryFormatter(); Hashtable ret = (Hashtable)bf.Deserialize(readMap.BaseStream); file.Close(); return ret; }
//Open Hash table file
Hashtable ht=OpenHashtableFile("ha.dat");
//Save Hash table into file
SaveHashtableFile(ht,"ha.dat");
No comments:
Post a Comment