RegistryKey.GetValue

solus

Freshman
Joined
Apr 5, 2003
Location
Phoenix
C#:
		public string GetValue( string SubKey )
		{
			RegistryKey Key = Registry.CurrentUser.OpenSubKey( KeyPath );

			if ( Key.GetValue( SubKey ) != null )
			{
				string Value = Key.GetValue( SubKey ).ToString();
				Key.Close();

				return Value;
			}

			else
			{
				return "";
			}
		}

This throws an exception: System.NullReferenceException: Object reference not set to an instance of an object.
At Line: "if ( Key.GetValue( SubKey ) != null )"

What am I doing wrong? Oo
 
Top Bottom