Winforms 中的 HTMLEncode

发布于 2024-09-18 20:04:21 字数 297 浏览 2 评论 0原文

我有一个 Winform 应用程序,在其中检查 XML 中是否存在完全限定的文件名 c:\somefolder\my file name.txt

不幸的是,XML 保存了 html 编码的字符串,因此 c:\somefolder\my file name.txt 变成 c:/somefolder/my%20file%20name.txt (不是从反斜杠更改为正斜杠,并用 %20 代替空格)。

如何在 winform 应用程序中对字符串进行 HTMLEncode?

I have a Winform application in which I am checking if a fully qualified file name c:\somefolder\my file name.txt exists in the XML.

Unfortunately, the XML holds the strings html encoded so c:\somefolder\my file name.txt becomes c:/somefolder/my%20file%20name.txt (not the change from backslash to forwardslash, and the %20 instead of blankspace).

How do I HTMLEncode strings in my winform app?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

獨角戲 2024-09-25 20:04:22

您也可以尝试 Uri.EscapeDataString(STRING_HERE) (无需参考),适用于 Asp.net 和WinForms。

You may also Try Uri.EscapeDataString(STRING_HERE) (No reference required), works in Asp.net & WinForms.

长途伴 2024-09-25 20:04:21

尝试

System.Web.HttpUtility.HtmlEncode(foo);

您需要添加对 System.Web.dll 的引用

try

System.Web.HttpUtility.HtmlEncode(foo);

you will need to add a reference to System.Web.dll

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文