如何使用ASP.Net将Rtf转换为文本?
如何使用ASP.Net将RTF转换为文本格式?您有相关说明 在C中#如何使用ASP.Net将Rtf转换为文本?,asp.net,text,rtf,Asp.net,Text,Rtf,如何使用ASP.Net将RTF转换为文本格式?您有相关说明 在C中# 我冒昧地把你的“指挥”风格的帖子变成了一个问题。我们很乐意提供帮助,但我们不喜欢被人指手画脚。这在winforms中可以工作,但在asp.net应用程序中可能会导致严重问题。您可以获得“无法创建windows句柄”exception@Sam如果删除Windows.Forms.MessageBox行,则应该可以正常工作。我刚刚放弃了整个例子。 class ConvertFromRTF { static void Main
我冒昧地把你的“指挥”风格的帖子变成了一个问题。我们很乐意提供帮助,但我们不喜欢被人指手画脚。这在winforms中可以工作,但在asp.net应用程序中可能会导致严重问题。您可以获得“无法创建windows句柄”exception@Sam如果删除Windows.Forms.MessageBox行,则应该可以正常工作。我刚刚放弃了整个例子。
class ConvertFromRTF
{
static void Main()
{
string path = @"test2.rtf";
//Create the RichTextBox. (Requires a reference to System.Windows.Forms.dll.)
System.Windows.Forms.RichTextBox rtBox = new System.Windows.Forms.RichTextBox();
// Get the contents of the RTF file. Note that when it is
// stored in the string, it is encoded as UTF-16.
string s = System.IO.File.ReadAllText(path);
// Display the RTF text.
System.Windows.Forms.MessageBox.Show(s);
// Convert the RTF to plain text.
rtBox.Rtf = s;
string plainText = rtBox.Text;
// Display plain text output in MessageBox because console
// cannot display Greek letters.
System.Windows.Forms.MessageBox.Show(plainText);
// Output plain text to file, encoded as UTF-8.
System.IO.File.WriteAllText(@"output.txt", plainText);
}
}