Hello,
Is it possible to save a System.Collection.Queue object to the Registy?
Im trying the below code to save a Queue containing most Recent file name to the registry in the REG Binary format. Cant seem to get it work.
public static void saveRecentFile(string strFilePath){
try{
string strBaseKey = "MyApp\\RecentEvents";
//Open Key; RegistryKey key = Registry.CurrentUser.OpenSubKey(strBaseKey, true); //If Key does not exist then create it if (key == null){
Registry.CurrentUser.CreateSubKey(strBaseKey);}
Queue arrMRU = (Queue)key.GetValue("MRU");{
if (arrMRU == null){
arrMRU =
new Queue(intMaxMRUFileCount);arrMRU.Enqueue(strFilePath);
}
else{
if (arrMRU.Count == intMaxMRUFileCount){
arrMRU.Dequeue();
}
arrMRU.Enqueue(strFilePath);
}
//Save queue in registry in binary format
key.SetValue(
"MRU",arrMRU,RegistryValueKind.Binary);}
}
catch (Exception e){
MessageBox.Show(e.Message);}
}
Bechir BejaouiPosted Nov 14, 2008, 4:47 AM
Bechir BejaouiPosted Nov 14, 2008, 11:23 AM
leightonPosted Nov 14, 2008, 6:47 AM
I got it.
I wanted to register the queue itself.
Im doing it using Serialization to convert it to a byte array.
Thanks