Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Registry question (debug three lines of code for me?)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim Margarit - 26 Mar 2008 21:56 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.