顯示圖像:
復制代碼 代碼如下:
Image img = Image.FromFile( @"E:\image\bottle\2006122013203825344.jpg" );
Clipboard.SetDataObject( img );
RichTextBox.Paste( DataFormats.GetFormat( DataFormats.Bitmap ) );
顯示word
string filename = @"d:\隨筆.doc";
//C#讀取word文件之實例化COM
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
object fileobj = filename;
object nullobj = System.Reflection.Missing.Value; //打開指定文件(不同版本的COM參數個數有差異,一般而言除第一個外都用nullobj就行了)
Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open( ref fileobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj ); //取得doc文件中的文本
ResponseFormsMediator.RemindersRichTextBox.Text += doc.Content.Text; //C#讀取word文件之關閉文件
doc.Close( ref nullobj, ref nullobj, ref nullobj ); //C#讀取word文件之關閉COM wordApp.Quit( ref nullobj, ref nullobj, ref nullobj );