Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTMLEncode in Winforms

Tags:

c#

html-encode

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?

like image 933
Raj More Avatar asked Sep 10 '10 20:09

Raj More


2 Answers

try

System.Web.HttpUtility.HtmlEncode(foo);

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

like image 97
Diego Avatar answered Sep 28 '22 07:09

Diego


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

like image 35
highwingers Avatar answered Sep 28 '22 07:09

highwingers