开发者

How to display an .rtf file in a Powershell RichTextBox

I want to display the content of an RTF file in a Powershell RichTextBox.

I am trying to make a kind of custom EULA, and the easiest way to do it would be to write the content in an RTF fi开发者_JS百科le and then have it display in a RichTextBox on my form, so the user has to click a checkbox to accept it.

(I'm sure this sits between ServerFault and StackOverflow, but I'm guessing the DotNet gurus on here will know best. ;-) )

Cheers,

Ben


In case anyone else happens upon this wondering where the PowerShell RichTextBox control came from it's a reference to the one in System.Windows.Forms. Here's the code with prerequisite build up:

[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$rtb = New-Object System.Windows.Forms.RichTextBox
$rtb.LoadFile($path)


OK - that was easy. Should have got my lazy ass on Google a bit more before posting. Used RichTextFile.Loadfile(c:\myfile.rtf) and it worked a treat.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜