Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi there.

Does anyone know's how to read and write to the registry?

 

This is out of the topic but i'll ask here anyway.

I'm using filestream to read a file. It works but when the file is readonly, why can't i open it ? I've set the filestream to IO.FileMode.Open but still could not access it.

 

Thanks in advance.

Posted

Try specifying "FileAccess.Read" to your Filestream.

 

This is from MSDN:

FileStream s2 = new FileStream(name, FileMode.Open, FileAccess.Read, FileShare.Read);

Posted

Nop... right out the track man...

try Microsoft.Registry

 

or look to add a reference named Microsoft.Something.Registry

 

it'll look like this

then follow the Online Help

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted

I was answering his second question about file access, not the registry question.

 

Nop... right out the track man...

try Microsoft.Registry

 

or look to add a reference named Microsoft.Something.Registry

 

it'll look like this

then follow the Online Help

Posted

Oh... sorry... I was out the track duh !

So you're right then !

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted

(no worries :) )

 

Actually, here's some vb.net registry code I used a while back:

 



  Private Function RegistryGetString(ByVal registryPath As String, ByVal keyName As String) As String
       Try
           Dim objKey As RegistryKey
           
           'search HKEY_LOCAL_MACHINE subpaths:
           objKey = Registry.LocalMachine.OpenSubKey(registryPath )
           Return Convert.ToString(objKey.GetValue(keyName , ""))
       Catch ex As Exception
           ErrorLog(ex)
       End Try
   End Function

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...