我有一个包含双引号的注册表字符串,我必须编辑它。我知道“忽略了引号或者其他什么。我尝试了一个逐字字符串文字,但这给了我30多个错误。任何人都有任何建议吗?下面是代码块:
RegistryKey mavroKey = Registry.LocalMachine;
RegistryKey mavbridgeKey = mavroKey.OpenSubKey("SYSTEM\\CurrentControlSet\\services\\MavBridge\\", true);
mavbridgeKey.SetValue("ImagePath", " ", RegistryValueKind.String);
mavbridgeKey.Close();
字符串值为
"C:\Mavro\MavBridge\Server\MavBridgeService.exe" /service /data "..\Data"
由于 特雷弗海因斯
答案 0 :(得分:2)
使用逐字字符串,并且您想要使用引号时,只需要输入两次:
@"""C:\Mavro\MavBridge\Server\MavBridgeService.exe"" /service /data ""..\Data"""
使用普通字符串时,您可以使用\"
包含引号,并\\
包含反斜杠:
"\"C:\\Mavro\\MavBridge\\Server\\MavBridgeService.exe\" /service /data \"..\\Data\""