Saving RichTextBox contents as text

Archived support forum for customers who once purchased a PrimalForms product license. This forum is locked.
This topic is 13 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
trwood
Posts: 14
Last visit: Tue Jan 31, 2023 7:10 pm

Saving RichTextBox contents as text

Post by trwood »

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
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Saving RichTextBox contents as text

Post by davidc »

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
Last visit: Tue Jan 31, 2023 7:10 pm

Saving RichTextBox contents as text

Post by trwood »

David,Thanks for that. It'll also help me make sense of converting other MSDN C# examples in the future.Tom
This topic is 13 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.