private void toolStripButton4_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { IF_MDLLib.IFRegExp REG = new IFRegExp(); //{ // System.IO.StreamReader sr = new System.IO.StreamReader(openFileDialog1.FileName, Encoding.UTF8); // richTextBox1.Text = REG.rtf_text(sr.ReadToEnd(), 2); //} { System.IO.FileStream stream = System.IO.File.OpenRead(openFileDialog1.FileName); byte[] buff = new byte[stream.Length]; stream.Read(buff, 0, (int)stream.Length); IntPtr pBSTR = SysAllocStringByteLen(null, (UInt32)(buff.Length)); Marshal.Copy(buff, 0, pBSTR, buff.Length); richTextBox1.Text = REG.rtf_text(Marshal.PtrToStringBSTR(pBSTR), 1); Marshal.FreeBSTR(pBSTR); pBSTR = IntPtr.Zero; } System.Windows.Forms.MessageBox.Show("OK"); } }
private void toolStripButton6_Click(object sender, EventArgs e) { string str = @"{\rtf1\ansi\ansicpg932\deff0\nouicompat\deflang1033\deflangfe1041{\fonttbl{\f0\fnil\fcharset128 \'82\'6c\'82\'72 \'96\'be\'92\'a9;}} {\*\generator Riched20 6.3.9600}\viewkind4\uc1 \pard\sa200\sl276\slmult1\f0\fs22\lang17 dfadf\'82\'6c\'82\'72 \'96\'be\'92\'a9v\par } "; IF_MDLLib.IFRegExp REG = new IFRegExp(); richTextBox1.Text = REG.rtf_text(str, 2); }