如何使用默认模式保存文本文件? [英] how to save text file with it's default mode?

查看:75
本文介绍了如何使用默认模式保存文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么是家伙....我有一个程序,就像我以前讨论过的那样,就像一个记事本和iwan,当我保存一个文本文件并且我将字体大小设置为= 28或类似的东西时,现在无论何时何地我再次打开它,它会以与我设置的问题相同的设置打开 是不是.

hy guy's .... i have a programm as i discuss before like a notepad and iwan that when i save a text file and i set the font-size like =28 or something like that, now when anytime i open it again it will open with the same setting as i set,,, the problem is that it's not.

这是我拥有的保存按钮代码.

here is the save button code i have..

[代码]

[/code]

推荐答案

通常文本文件无法存储格式化的字符串.

Hi, in general text files cannot store formatted strings.

格式化的字符串可以以RTF格式,Word Doc,HTML等格式存储.

Formatted strings can be stored in Rich Text Format, Word Doc, HTML,..

在您的代码中,您试图将文件另存为文本文件.而是尝试将其保存为RTF格式.

In your code you are trying to save the file as text file. Instead try to save it as rich text format (rtf ).

私有void saveToolStripMenuItem_Click(对象发送者,EventArgs e ){字符串fnane ="; saveFileDialog1.FileName ="; saveFileDialog1.Filter =富文本格式| * .rtf |所有文件| *.*"; foreach(tabControl1.SelectedTab.Controls中的控件rhh){如果(rhh是RichTextBox){如果(saveFileDialog1.ShowDialog()!= DialogResult.Cancel){fnane = saveFileDialog1.FileName; (rhh为RichTextBox).SaveFile(fnane,RichTextBoxStreamType.RichText); }}}

private void saveToolStripMenuItem_Click(object sender, EventArgs e) { string fnane = ""; saveFileDialog1.FileName = ""; saveFileDialog1.Filter = "Rich Tex Format|*.rtf|All files|*.*"; foreach (Control rhh in tabControl1.SelectedTab.Controls) { if (rhh is RichTextBox) { if (saveFileDialog1.ShowDialog()!= DialogResult.Cancel) { fnane = saveFileDialog1.FileName; (rhh as RichTextBox).SaveFile(fnane, RichTextBoxStreamType.RichText); } } }



这篇关于如何使用默认模式保存文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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