当前位置:网站首页>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
.
边栏推荐
- The city chain technology platform is realizing the real value Internet reconstruction!
- To achieve good software testing results, it is a prerequisite to build a good testing environment
- C language: count the number of characters, numbers and spaces
- C language "Recursion Series": recursively realizing the n-th power of X
- mysql之Unknown table ‘COLUMN_STATISTICS‘ in information_schema (1109)
- 自定义注解之编译时注解(RetentionPolicy.CLASS)
- C language: bubble sort
- Swiperefreshlayout+recyclerview failed to pull down troubleshooting
- C#启动程序传递参数丢失双引号,如何解决?
- 买股票通过客户经理的开户二维码开户资金是否安全?想开户炒股
猜你喜欢
浏览器查看当前页面所有的监听事件
【OpenCV】—输入输出XML和YAML文件
UEFI: repair efi/gpt bootloader
C language: count the number of words in a paragraph
jmeter中csv参数化
Unity--Configurable Joint——简单教程,带你入门可配置关节
LVS-DR模式多网段案例
compiling stm32f4xx_it.c... “.\Objects\BH-F407.axf“ - 42 Error(s), 1 Warning(s).
Meaning of Jieba participle part of speech tagging
【515. 在每个树行中找最大值】
随机推荐
Getting to know the generation confrontation network (11) -- using pytoch to build wgan to generate handwritten digits
[summary] 1361- package JSON and package lock JSON relationship
How to become a software testing expert? From 3K to 17k a month, what have I done?
声纹技术(四):声纹识别的工程部署
atguigu----17-生命周期
How to choose an account opening broker? Is it safe to open an account online?
flutter 多语言的intl: ^0.17.0导不进去
【期末复习笔记】数字逻辑
EasyPlayer流媒体播放器播放HLS视频,起播速度慢的技术优化
六级易混词整理
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
C language: count the number of characters, numbers and spaces
Notes on key words in the original English work biography of jobs (III) [chapter one]
What is the role of software validation testing? What is the price of the confirmation test report?
UEFI: repair efi/gpt bootloader
About i/o -- the relationship between memory and CPU and disk
Openfoam: bottom layer
紧急行政中止令下达 Juul暂时可以继续在美国销售电子烟产品
Easyplayer streaming media player plays HLS video. Technical optimization of slow starting speed
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