0

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 file 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

Ben
  • 4,281
  • 8
  • 62
  • 103

2 Answers2

4

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)
xcud
  • 14,422
  • 3
  • 33
  • 29
1

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.

Ben
  • 4,281
  • 8
  • 62
  • 103