An object-oriented programming language developed by Microsoft that can be used in .NET.
Try to use If valueName <> "" instead of If Equals(valueName, "").
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello
Having problem converting this code to vb.net:
https://learn.microsoft.com/en-us/answers/questions/1210974/backup-registry-key-values
Does not work, empty file is saved, any idea where's the problem? :(
' Check if the registry key exists
Dim regKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\company\appname")
If regKey Is Nothing Then
MsgBox("Registry key does not exist")
Return
End If
' Backup registry keys to text file
Using writer As StreamWriter = New StreamWriter("d:\backup.txt")
Dim valueNames As String() = regKey.GetValueNames()
For Each valueName In valueNames
If Equals(valueName, "") Then
Dim value As String = regKey.GetValue(valueName).ToString()
writer.WriteLine([String].Format("{0}={1}", valueName, value))
'writer.WriteLine("{valueName}={value}")
End If
Next
End Using
An object-oriented programming language developed by Microsoft that can be used in .NET.
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
Answer accepted by question author
Try to use If valueName <> "" instead of If Equals(valueName, "").