C# 编辑包含引号的注册表字符串

C# 编辑包含引号的注册表字符串,c#,string,registry,C#,String,Registry,我有一个注册表字符串,其中包含必须编辑的双引号。我知道\“忽略引号或其他内容。我尝试了逐字字符串文字,但这给了我30多个错误。有人有什么建议吗?下面是代码块: RegistryKey mavroKey = Registry.LocalMachine; RegistryKey mavbridgeKey = mavroKey.OpenSubKey("SYSTEM\\CurrentControlSet\\services\\MavBridge\\", true); mavbri

我有一个注册表字符串,其中包含必须编辑的双引号。我知道\“忽略引号或其他内容。我尝试了逐字字符串文字,但这给了我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"
谢谢
特雷弗·海因斯(Trevor Heins)

使用逐字记录字符串时,如果要使用引号,只需键入两次:

@"""C:\Mavro\MavBridge\Server\MavBridgeService.exe"" /service /data ""..\Data"""
使用普通字符串时,可以使用
\“
包含引号,使用
\
包含反斜杠:

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