B
Bry
Having mastered reading a multi_sz from the registry into an array
using:
// Max of 999 is fine in this instance
string[] myArray = new string[999];
myArray = (string[]) (myRegKey.GetValue("RegValue"));
// myArray will now contain a small number of elements with data in
them
I'm trying to do the opposite and write it back to the registry using:
// I may have added a few elements to the array since
// it was loaded from the registry in the above example.
myRegKey.SetValue("RegValue", myArray, RegistryValueKind.MultiString);
but the last line gives a "RegistryKey.SetValue does not allow a
String[] that contains a null String reference." exception at run time.
The exception occurs because only the first few elements of the array
contain real data, the exception is thrown because the other elements
all contain 'null'.
How can I write only the used elements to the multi_sz registry value?
Note that the array will never contain a fixed number of elements, but
the max of 999 will never be achieved (although I have allowed for this
occuring in my code).
Thanks.
using:
// Max of 999 is fine in this instance
string[] myArray = new string[999];
myArray = (string[]) (myRegKey.GetValue("RegValue"));
// myArray will now contain a small number of elements with data in
them
I'm trying to do the opposite and write it back to the registry using:
// I may have added a few elements to the array since
// it was loaded from the registry in the above example.
myRegKey.SetValue("RegValue", myArray, RegistryValueKind.MultiString);
but the last line gives a "RegistryKey.SetValue does not allow a
String[] that contains a null String reference." exception at run time.
The exception occurs because only the first few elements of the array
contain real data, the exception is thrown because the other elements
all contain 'null'.
How can I write only the used elements to the multi_sz registry value?
Note that the array will never contain a fixed number of elements, but
the max of 999 will never be achieved (although I have allowed for this
occuring in my code).
Thanks.