Editing a registry string containing quotation marks

I have a registry string containing double quotes that I need to edit. I know that "ignores quotes or something like that." I tried a string literal, but that gave me 30+ errors. Anyone have any suggestions? Heres the code block:

    RegistryKey mavroKey = Registry.LocalMachine;
    RegistryKey mavbridgeKey = mavroKey.OpenSubKey("SYSTEM\\CurrentControlSet\\services\\MavBridge\\", true);
    mavbridgeKey.SetValue("ImagePath", " ", RegistryValueKind.String);
    mavbridgeKey.Close();

String value

    "C:\Mavro\MavBridge\Server\MavBridgeService.exe" /service /data "..\Data"

Thanks Trevor Haines

+3
source share
1 answer

When using a shorthand line and you want to use quotation marks, you just need to enter them twice:

@"""C:\Mavro\MavBridge\Server\MavBridgeService.exe"" /service /data ""..\Data"""

when using a normal line, you can use \"to include a quote and \\to include a backslash:

"\"C:\\Mavro\\MavBridge\\Server\\MavBridgeService.exe\" /service /data \"..\\Data\""
+2
source

All Articles