c# - Saving source code formatting to TXT file -
i trying extract source code webpage , save text file. however, want keep formatting of source code.
my code below.
// block fetches source code url entered. private void buttonfetch_click(object sender, eventargs e) { using (webclient webclient = new webclient()) { string s = webclient.downloadstring("http://www.ebay.com"); clipboard.settext(s, textdataformat.text); string[] lines = { s }; system.io.file.writealllines(@"c:\users\user\dropbox\personal projects\writelines.txt", lines); messagebox.show(s.tostring(), "source code", messageboxbuttons.okcancel, messageboxicon.asterisk); } }
i text file show source code formatted in messagebox.
messagebox screenshot:
text file screenshot:
how go getting text document's formatting same in messagebox?
i agree comment, i'll add note. if open in notepad++, n++ detect line endings , display file nicely you. in notepad++ can go menu , change line endings windows. if re-save , open in notepad itself, correctly. problem base notepad doesn't understand different line endings.
hope helps.
Comments
Post a Comment