Dark Kai Posted March 22, 2004 Posted March 22, 2004 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. Quote
mocella Posted March 22, 2004 Posted March 22, 2004 Try specifying "FileAccess.Read" to your Filestream. This is from MSDN: FileStream s2 = new FileStream(name, FileMode.Open, FileAccess.Read, FileShare.Read); Quote
Arch4ngel Posted March 24, 2004 Posted March 24, 2004 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 Quote "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
mocella Posted March 24, 2004 Posted March 24, 2004 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 Quote
Arch4ngel Posted March 24, 2004 Posted March 24, 2004 Oh... sorry... I was out the track duh ! So you're right then ! Quote "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
mocella Posted March 24, 2004 Posted March 24, 2004 (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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.