4
I am developing a program in C# and would like to know how to save the text of a RichTextBox
format .xml
or .html
or .txt
.
4
I am developing a program in C# and would like to know how to save the text of a RichTextBox
format .xml
or .html
or .txt
.
3
The question does not give details but the simplest way to do this is by using the WriteAllText()
:
File.WriteAllText(caminhoCompletoDoArquivo, seuRichTextBox.Text);
This method is ready for what you want. As its name says it writes a text in the file specified in caminhoCompletoDoArquivo
) does not need to be a variable, it can be a text with the file path, e.g.: " c: minhaapp xml.txt") and it will take the content to be written directly to the control via the property Text
of the object seuRichTextBox
.
To read:
var texto = File.ReadAllText(caminhoCompletoDoArquivo);
I put in the Github for future reference.
Documentation of ReadAllText()
.
Of course the data in XML and HTML format must be in order. Saving does not guarantee anything. These methods only do the saving of a text without knowing what it means and whether it is right.
Browser other questions tagged c# .net string filing-cabinet
You are not signed in. Login or sign up in order to post.
You already have some code developed to put in your question?
– Leonel Sanches da Silva
No but I posted this question because I’m a beginner and so I don’t know how to do this.
– user30226