如何在 Powershell RichTextBox 中显示 .rtf 文件

发布于 2024-09-07 02:47:30 字数 239 浏览 2 评论 0原文

我想在 Powershell RichTextBox 中显示 RTF 文件的内容。

我正在尝试制作一种自定义 EULA,最简单的方法是将内容写入 RTF 文件,然后将其显示在我的表单上的 RichTextBox 中,因此用户必须单击复选框才能接受它。

(我确信这位于 ServerFault 和 StackOverflow 之间,但我猜这里的 DotNet 专家会最了解。;-))

干杯,

Ben

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

百善笑为先 2024-09-14 02:47:58

好吧——这很容易。在发帖之前我应该​​在谷歌上再多看看我的懒惰屁股。使用 RichTextFile.Loadfile(c:\myfile.rtf) 并且效果很好。

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.

家住魔仙堡 2024-09-14 02:47:53

如果其他人遇到这种情况,想知道 PowerShell RichTextBox 在哪里control 来自它对 System.Windows.Forms 中的一个引用。这是构建先决条件的代码:

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

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文