Process.Start - 将 html 代码作为参数传递给 exe [英] Process.Start - Pass html code to exe as argument

查看:90
本文介绍了Process.Start - 将 html 代码作为参数传递给 exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用下面的代码从 Windows 服务启动一个可执行文件,我需要将 html 代码(存储在变量中)作为参数传递.我用双引号转义,但这不起作用.我需要做什么才能正确传递它?预先感谢您提供的任何指导.

I am using the code below to start a executable file from a windows service and I need to pass html code (stored in a variable) as an argument. I am escaping with double quotes but this is not working. What do I need to do in order to pass this correctly? Thanks in advance for any guidance that is offered.

服务内部:

Process.Start(@"E:\Program Files\MyApp.exe", dr["rec"].ToString() +
                                  " \"" + subject + "\" \"" + htmlVar);

然后在 MyApp.exe 中:

and then within MyApp.exe:

static void Main(string[] args)
{
    Program MyProg = new Program();
    MyProg.MyMeth(args[0].ToString(), args[1].ToString(), args[2].ToString());
}

exe 文件只是一个处理电子邮件发送的简单应用程序.dr["rec"].ToString() 是收件人的电子邮件地址.变量主题"将包含电子邮件的主题.变量htmlVar"可以包含任何内容,div、图像、超链接等,而且 html 代码可能很长.我不应该尝试将这么多数据作为参数传递吗?再次感谢您的帮助.

The exe file is just a simple app that handles the sending of emails. dr["rec"].ToString() is the email address of the recipient. The variable "subject" will contain the subject of the email. The variable "htmlVar" could contain anything, divs, images, hyperlinks, etc.. and the html code could be quite lengthy. Should I not be trying to pass this much data as an argument? Thanks again for the help.

推荐答案

您可能需要对以下字符进行编码以使其可在命令行参数中通过:

  • 双引号
  • 回车
  • 换行

这篇关于Process.Start - 将 html 代码作为参数传递给 exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆