![](/img/trans.png)
[英]Add app.config file for console application in Visual studio for mac
[英]html tags in app.config file in .net console application
我需要在 C# 控制台应用程序的 app.config 文件中添加 html 标签。 我试过了
<p>
但它对我有用。 有什么想法吗?
首先,向您的项目添加对System.Web
的引用。 然后,您可以通过HTML 编码来存储您的 HTML。 只需对存储在配置文件中的值调用HttpUtility.UrlDecode()
。
你的配置文件:
<appSettings>
<add key="HTML" value="<p>My paragraph</p>"/>
</appSettings>
您的代码:
string html = HttpUtility.UrlDecode(ConfigurationManager.AppSettings["HTML"]);
认为你真的想要
字符串 html = HttpUtility.HtmlDecode(ConfigurationManager.AppSettings["HTML"]);
如果没问题,您可以创建一个单独的 HTML 文件并使用 C# 代码读取内容。 然后将该变量用于您的代码。
像下面
string htmdata = File.ReadAllText(@"D:\\Sendmail\\email.html");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.