HTMLEncode in Winforms

I have a Winform application in which I check to see if the full file name exists in XML c:\somefolder\my file name.txt.

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

How to HTMLEncode strings in my winform application?

+5
source share
2 answers

to try

System.Web.HttpUtility.HtmlEncode(foo);

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

+16
source

You can also try Uri.EscapeDataString (STRING_HERE) (no link required), works in Asp.net and WinForms.

+2
source

All Articles