当前位置:网站首页>C # startup program loses double quotation marks for parameters passed. How to solve it?
C # startup program loses double quotation marks for parameters passed. How to solve it?
2022-06-25 08:50:00 【Sir, silence first】
c# Parameters passed after starting the program do not have double quotes
bug Exhibition


C# Program start code
static void Main(string[] args)
{
Dictionary<string, string> dic = new Dictionary<string, string>();// Create a parameter transfer object
dic.Add("dst", "ddd");
dic.Add("dasdst", "ddd");
var requesDataStr = JsonConvert.SerializeObject(dic);// Serializing objects , For parameter passing
ProcessStartInfo startInfo = new ProcessStartInfo();// Create a startup program ProcessStartInfo
startInfo.FileName = "MD5Encryption.exe"; // The name of the launched Application
startInfo.Arguments = @requesDataStr;// Parameters passed to the starting program
Process.Start(startInfo);// Start the program
Console.WriteLine(" Program started ");
Console.ReadKey();
}
C# The code of the program being started
static void Main(string[] args)
{
Console.WriteLine(args[0]);// Just print the passed string
Console.ReadKey();
Console.ReadKey();
}
The effect is the picture above
Solution
Escape the double quotation marks inside
Code in 23 That's ok

Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("dst", "ddd");
dic.Add("dasdst", "ddd");
var requesDataStr = JsonConvert.SerializeObject(dic);
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "MD5Encryption.exe"; // The name of the launched Application
requesDataStr = requesDataStr.Replace("\"","\\\"");
startInfo.Arguments = @requesDataStr;
Process.Start(startInfo);
Console.WriteLine(" Program started ");
Console.ReadKey();
Replace the string with another string
Code No. 24 That's ok
String substitution
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("dst", "ddd");
dic.Add("dasdst", "ddd");
var requesDataStr = JsonConvert.SerializeObject(dic);
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "MD5Encryption.exe"; // The name of the launched Application
requesDataStr = requesDataStr.Replace("\"", "#");
startInfo.Arguments = @requesDataStr;
Process.Start(startInfo);
Console.WriteLine(" Program started ");
Console.ReadKey();
The string is replaced again
static void Main(string[] args)
{
args[0] = args[0].Replace("#", "\"");
Console.WriteLine(args[0]);
}
Modify the encoding format of the string
I won't , This method is not available for the time being .
No comments or personal letters

.
边栏推荐
- Hyper-v:Hyper-v 第 1 代或第 2 代虚拟机
- Check whether the point is within the polygon
- 声纹技术(五):声纹分割聚类技术
- [MySQL] understanding of transactions
- flutter 多语言的intl: ^0.17.0导不进去
- What does openid mean? What does "token" mean?
- atguigu----18-组件
- UEFI:修复 EFI/GPT Bootloader
- Is it safe to buy stocks and open accounts through the account QR code of the account manager? Want to open an account for stock trading
- 故障:Outlook 收发邮件时的 0x800CCC1A 错误
猜你喜欢

Unity--Configurable Joint——简单教程,带你入门可配置关节

C language: find all integers that can divide y and are odd numbers, and put them in the array indicated by B in the order from small to large

Jmeter接口测试,关联接口实现步骤(token)

C#启动程序传递参数丢失双引号,如何解决?

【无标题】**数据库课设:三天完成学生信息管理系统**

LVS-DR模式单网段案例

C language: count the number of characters, numbers and spaces

云网络技术的好处以及类型

Emergency administrative suspension order issued Juul can continue to sell electronic cigarette products in the United States for the time being

如何设计测试用例
随机推荐
声纹技术(六):声纹技术的其他应用
annotation lib 和 processor lib如何引用
二、训练fashion_mnist数据集
获取扫码的客户端是微信还是支付宝
City Chain technology platform, really Realizing value Internet reconstruction!
Analysis of a video website m3u8 non perceptual encryption
声纹技术(五):声纹分割聚类技术
故障:Outlook 收发邮件时的 0x800CCC1A 错误
Getting to know the generation confrontation network (11) -- using pytoch to build wgan to generate handwritten digits
Discrimination of configuration, software configuration items and software configuration management items
如何设计测试用例
Getting to know the generation confrontation network (12) -- using pytoch to build wgan-gp to generate handwritten digits
Iframe is simple to use, iframe is obtained, iframe element value is obtained, and iframe information of parent page is obtained
关掉一个线程
Object.defineProperty也能监听数组变化?
[MySQL] understanding and use of indexes
socket编程——epoll模型
How to increase the monthly salary of software testing from 10K to 30K? Only automated testing can do it
Stimulsoft ultimate presents reports and dashboards
WebGL发布之后不可以输入中文解决方案