copied from MSDN help on Registry class:
string[] tArray = (string[])Registry.GetValue(keyName,"TestArray",
newstring[] {"Default if TestArray does not exist."});
Here's my code:
string[] defaultExt = {".mp4",".avi"};
string[] validExts;
validExts = (string[])Registry.GetValue("myTest","validExts",defaultExt);
if the registry is empty, this always returns null. I'm expecting
{".mp4",".avi"}.
if I make the next line:
if (validExts = null) Registry.SetValue("myTest","validExts",defaultExt);
and then repeat the getvalue line, it produces the expected result.
Is this a bug or "you just can't do that". The line from the help makes
it seem that it should work.
Jim
NvrBst - 27 Mar 2008 02:16 GMT
> copied from MSDN help on Registry class:
>
[quoted text clipped - 20 lines]
>
> Jim
From MSDN:
----------
Return Value
Type: System..::.Object
a null reference (Nothing in Visual Basic) if the subkey specified by
keyName does not exist; otherwise, the value associated with
valueName, or defaultValue if valueName is not found.
----------
Could be because the subkey your trying to access doesn't exsist (not
just the valueName).
Jim Margarit - 27 Mar 2008 15:41 GMT
>> copied from MSDN help on Registry class:
>>
[quoted text clipped - 32 lines]
> Could be because the subkey your trying to access doesn't exsist (not
> just the valueName).
Hmm, could be. It is the first line of registry reads. I'll have to
rearrange the order and see if it makes a difference.
Jim