[英]Make a richtextbox open from file in a set location
I need to have a richtextbox (rtbUsers) load up a .txt or .rtf (Whatever is easiest) on either form loadup or when a button is pressed (btnLoad) from: C:\\ProgramData\\Project\\test.txt 我需要一个Richtextbox(rtbUsers)在表单加载时或从以下位置按下按钮(btnLoad)时加载.txt或.rtf(最简单的方法):C:\\ ProgramData \\ Project \\ test.txt
The only code I have found is for the openfile dialogue, but I need it from a set location. 我找到的唯一代码是用于openfile对话的,但是我需要从一个固定的位置进行。 So I am asking if anyone could please give me the code that I need.
所以我问是否有人可以给我我需要的代码。 Thanks :)
谢谢 :)
Just call the LoadFile method: 只需调用LoadFile方法:
richTextBox1.LoadFile("mypathandfile.rtf")
For a text file, there is an overload you can use: 对于文本文件,可以使用以下重载:
richTextBox1.LoadFile("mypathandfile.txt", RichTextBoxStreamType.PlainText)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.