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.
TypeScript
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 BejaouiRank #144 · 15.9K pointsPosted Nov 13, 2008, 11:47 PM EST
leighton4 pointsPosted Nov 14, 2008, 1:47 AM EST
I got it.
I wanted to register the queue itself.
Im doing it using Serialization to convert it to a byte array.
Thanks
1 short reply
Bechir BejaouiRank #144 · 15.9K pointsPosted Nov 14, 2008, 6:23 AM EST