2011-09-27 171 views
1

那麼問題是。無論如何將文本和/或文件複製到Windows剪貼板,而不使用.NET的Clipboard Class複製到沒有System.Windows.Forms.Clipboard的剪貼板?

+2

爲什麼你想這樣做? –

+0

你爲什麼想要做到這一點?有多種方式,包括WPF剪貼板類,並直接與剪貼板API交互......但它會幫助你知道你的動機...... – Jeff

+0

當然......直接與Windows剪貼板接口,這正是剪貼板類的作用。 @ JeffN825 - 什麼......每個用戶的WPF剪貼板都不能使用,因爲它的「來自.NET的剪貼板類」 –

回答

6

取決於如果我在標題或文本回答這個問題......你可以訪問System.Windows.Clipboard無需訪問System.Windows.Forms的...

string textData = "I want to put this string on the clipboard."; 

// After this call, the data (string) is placed on the clipboard and tagged 
// with a data format of "Text". 
System.Windows.Clipboard.SetData(DataFormats.Text, (Object)textData); 
+1

這就是WPF剪貼板... – Jeff

+0

@ JeffN825 - 它基本上完全相同,不同的dll,只是修改爲支持表示框架。 –

+0

不,它不是。他們是不同的。 – Jeff