![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
|
Exception writing to registry... why?
I am using a bit of code in C# to write a simple string value to the registry with very very little luck, it keeps trowing an exception every single time saying I do not have write access to the registery, or it can not write to the registry (I forget extactly)... this is the offending code:
RegistryKey registryKey = Registry.CurrentUser; registryKey - registryKey.OpenSubKey( @"Software\CrDev Consulting\WinVOBGlue\" ); registryKey.SetValue( "tempdir", this.temporaryDirectory.Text ); registryKey.Close( ) the tempdir value already exists within the registry, basically all I am doing is overwriting it, I tried deleting it first but as soon as Delete is called it says that it can not write the registry... is there something I am doing wrong here? Any ideas as to what could be causing this error? I am running the application as an administrator, and it can read the value without any problems... but since it is HKCU there should be no problems, even if I am not the administrator when writing to this key. Any help would be greatly appreciated.
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#2 |
|
Expert Programmer
|
Oh yeah, I feel dumb for this one.... the problem is actually with OpenSubKey( "..." ); This function is overloaded and that is the ReadOnly form of the function... OpenSubKey( "...", true ); is how the function is called to open the key with write permissions.. took me an entire day to figure this one out, lol.
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Sep 2004
Posts: 207
Rep Power: 5
![]() |
Just need to make sure what you have is exactly like the examples. They almost always work. :p
__________________
_______________________________ BlazingWolf |
|
|
|
|
|
#4 |
|
Expert Programmer
|
Actually I failed to realize that the problem was with that function to begin with. i thought it was a permission problem or a problem with the set value function. It was not until I did a bit of searching though google that I saw an example that used a second value for the OpenSubKey function, and then it all made sense.
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|