如何以与在wpf中显示相同的格式保存文本框中的文本? [英] How to save the text from textbox in same format as displaying in wpf?

查看:69
本文介绍了如何以与在wpf中显示相同的格式保存文本框中的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个带文字的文本框,我只想将文件保存在文件夹中,其格式与文本框中显示的格式相同。 br $> b $ b

代码:

Hi,

I have a textbox with text and I just want to save the file in a folder with the same format as it displaying in the textbox.

Code:

System.IO.File.WriteAllText(completedpath + "\\" + stringwithoutextension + ".txt", s);





以下是文本框中显示的文本文件...





Below is the Text file displaying in textbox ...

BillnorOOO0043S3178022075 Ifilllperiod: 25.01.15 to 24.02.15 lBilldate:25,02.7S lYourtalkplan:MBB~C__V_‘l599_30d_12GB_FU 3G

Mr.JayanrShaiwale
BOROSILGLASSWORKSLJMITED

1101.11th Hrcrescenzo G Block
PlotNo-C—380ppMCAClub
Bandra KurlaComple>< Bandra East
MUMB/-\l400051



(detailsonpage3)

Vodafoneno. 9167130



Vodafone mdxa Limited

PenfmsulaCorporateParR,GanpatRaol<adam Marg,LowerPareL,Mumbai—40001Z’>.Sen/Icetaxregn:»\AAC}-|5332BSTOO1





目前,我将文件保存在一行中,没有任何换行符或空格





Currently, I am saving the file in a single line without any line break or spaces

BillnorOOO0043S3178022075 Ifilllperiod: 25.01.15 to 24.02.15 lBilldate:25,02.7Sourtalkplan:MBB~C__V_‘l599_30d_12GB_FU 3G
Mr.JayanrShaiwaleBOROSILGLASSWORKSLJMITED1101.11th Hrcrescenzo G Block
PlotNo-C—380ppMCAClubBandra KurlaComple>< Bandra East
MUMB/-\l400051(detailsonpage3)Vodafoneno. 9167130904Vodafone mdxa Limited





谢谢



Thanks

推荐答案



's'代表什么?



Hi,
What does 's' represents?

System.IO.File.WriteAllText(completedpath + "\\" + stringwithoutextension + ".txt", s);





简单的解决方案是从RichTextbox中提取文本然后保存文本,





simple solution is to extract text from RichTextbox and then save the text ,

string myText = new TextRange(rchtextbox.Document.ContentStart, rchtextbox.Document.ContentEnd).Text;
System.IO.File.WriteAllText(completedpath + "\\" + stringwithoutextension + ".txt", myText )


这篇关于如何以与在wpf中显示相同的格式保存文本框中的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆