我的问题是我无法使用格式正确的文本将RTF文件加载到Web浏览器中。
我在下面的方案中取得了成功,我将第一个加载rtf文件放入richtextbox,然后将文本粘贴到Web浏览器。但问题是网页浏览器没有正确显示文字。
我的代码看起来像
public void LoadMyFile()
{
RichTextBox Rich1 = new RichTextBox();
// Create an OpenFileDialog to request a file to open.
OpenFileDialog openFile1 = new OpenFileDialog();
// Initialize the OpenFileDialog to look for RTF files.
openFile1.DefaultExt = "*.rtf";
openFile1.Filter = "RTF Files|*.rtf";
// Determine whether the user selected a file from the OpenFileDialog.
if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
openFile1.FileName.Length > 0)
{
// Load the contents of the file into the RichTextBox.
richTextBox1.LoadFile(openFile1.FileName);
}
DataObject dto = new DataObject();
dto.SetData(DataFormats.Rtf, true,richTextBox1.Rtf);
dto.SetData(DataFormats.Text, true,richTextBox1.Text);
Clipboard.Clear();
Clipboard.SetDataObject(dto);
Paste();
}
请注意,粘贴功能正常工作确切的问题是当我复制形式富文本框时,还有其他方法可以做到这一点或任何建议。
提前致谢