I have a registry string that contains double quotes that I have to edit. I know the \" ignores the quotes or whatever. I tried a verbatim string literal but that gave me 30+ errors. Anyone have any suggestions? Heres the block of code:
RegistryKey mavroKey = Registry.LocalMachine;
RegistryKey mavbridgeKey = mavroKey.OpenSubKey("SYSTEM\\CurrentControlSet\\services\\MavBridge\\", true);
mavbridgeKey.SetValue("ImagePath", " ", RegistryValueKind.String);
mavbridgeKey.Close();
The string value is
"C:\Mavro\MavBridge\Server\MavBridgeService.exe" /service /data "..\Data"
Thanks Trevor Heins
When using a verbatim string, and you want to use quotes, you just need to type them twice:
@"""C:\Mavro\MavBridge\Server\MavBridgeService.exe"" /service /data ""..\Data"""
when using a normal string, you can use \" to include a quote, and \\ to include a backslash:
"\"C:\\Mavro\\MavBridge\\Server\\MavBridgeService.exe\" /service /data \"..\\Data\""
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With