当前位置:网站首页>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

.
边栏推荐
- socket编程——epoll模型
- What does openid mean? What does "token" mean?
- EasyPlayer流媒体播放器播放HLS视频,起播速度慢的技术优化
- 声纹技术(一):声纹技术的前世今生
- Exchange: manage calendar permissions
- In Section 5 of bramble pie project practice, Nokia 5110 LCD is used to display Hello World
- Hyper-v:Hyper-v 第 1 代或第 2 代虚拟机
- Exchange:管理日历权限
- 【MYSQL】索引的理解和使用
- C#启动程序传递参数丢失双引号,如何解决?
猜你喜欢

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

How to become a software testing expert? From 3K to 17k a month, what have I done?

UEFI:修复 EFI/GPT Bootloader
![[515. find the maximum value in each tree row]](/img/0d/7ae494a5b3df3917ab95ebf61a1c96.png)
[515. find the maximum value in each tree row]

Exchange: manage calendar permissions

cazy長安戰役八卦迷宮

Exchange:管理日历权限

Getting to know the generation confrontation network (11) -- using pytoch to build wgan to generate handwritten digits

C language "recursive series": recursive implementation of 1+2+3++ n

Incluxdb time series database
随机推荐
[515. find the maximum value in each tree row]
tp5与tp6的区别是啥呀?
Is it really safe to pay new debts? Is it risky
Day 5 script and UI System
《乔布斯传》英文原著重点词汇笔记(五)【 chapter three 】
【总结】1361- package.json 与 package-lock.json 的关系
Hyper-v:hyper-v generation 1 or generation 2 virtual machines
某次比赛wp
Software engineering review questions
Swiperefreshlayout+recyclerview failed to pull down troubleshooting
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
(翻译)采用字母间距提高全大写文本可读性的方式
自定义注解之编译时注解(RetentionPolicy.CLASS)
Level 6 easy to mix words
从别人库里拷贝的游戏如何再自己的库里显示
[operation tutorial] how does the tsingsee Qingxi video platform import the old database into the new database?
[MySQL] understanding and use of indexes
《乔布斯传》英文原著重点词汇笔记(四)【 chapter two 】
atguigu----01-脚手架
LVS-DR模式单网段案例