Saving RichTextBox contents as text

Archived support forum for customers who once purchased a PrimalForms product license. This forum is locked.
User avatar
trwood
Posts: 14
Joined: Mon Jul 12, 2010 6:14 pm

Saving RichTextBox contents as text

Post by trwood » Mon Sep 13, 2010 7:39 pm

Hi.I'm running PF 1.1.10, and trying to save the contents of a RichTextBox to a text file. I have got all of the method info from the MSDN page, but can not find out how to represent the 'RichTextBoxStreamType.PlainText' value. RTF works fine, but I don't want to save log files to RTF format.Code:$sfd1.DefaultExt = "*.txt"$sfd1.Filter = "Text Files|*.txt"$sfd1.CheckFileExists = $false$sfd1.InitialDirectory = $txtDefaultOutputFolder.Text$sfd1.ShowDialog()$strTmpFileName = $sfd1.FileName$txtProgress.SaveFile($strTmpFileName, RichTextBoxStreamType.PlainText)Tom

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Saving RichTextBox contents as text

Post by davidc » Tue Sep 14, 2010 1:42 am

To order to use enumerators or any static member in PowerShell you have to use the following format:
[System.Windows.Forms.RichTextBoxStreamType]::PlainText

PowerShell also allows you to specify enumerators by text name only, but you will not get the benefit of PrimalSense.

$txtProgress.SaveFile($strTmpFileName, "PlainText")

David
David
SAPIEN Technologies, Inc.

User avatar
trwood
Posts: 14
Joined: Mon Jul 12, 2010 6:14 pm

Saving RichTextBox contents as text

Post by trwood » Tue Sep 14, 2010 6:48 pm

David,Thanks for that. It'll also help me make sense of converting other MSDN C# examples in the future.Tom