user3719173
user3719173

Reputation: 387

WPF add html string to HTML file and save it

i have WPF application which have an HTML string as below. how can i creeate a new HTML file base on this string and save this file in my application folder in code behind?

string str = "<h2><u>TEST</u></h2><div style='margin:0 auto;'>";

Upvotes: 0

Views: 844

Answers (1)

faby
faby

Reputation: 7556

you can do something like this

using (FileStream fs = new FileStream("document.html", FileMode.Create)) 
{ 
    using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8)) 
    { 
        sw.WriteLine("<h2><u>TEST</u></h2><div style='margin:0 auto;'>"); 
    } 
} 

Upvotes: 1

Related Questions