Código de la aplicación
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# Función que convierte el fichero .rtf en .txt y abre el fichero .txt en el Notepad function convertir($nombrertf) { $rtf = New-Object System.Windows.Forms.RichTextBox $rtf.Rtf = [System.IO.File]::ReadAllText($nombrertf) $rtf.Text | Out-File $nombrertf.replace(".rtf",".txt") notepad $nombrertf.replace(".rtf",".txt") } # Formulario con un botón que pregunta la ruta y una vez indicado el fichero .rtf lo convierte a .txt $form = [System.Windows.Forms.Form] @{ Text = 'Convertir .rft a .txt' } $ShowDialog = [System.Windows.Forms.OpenFileDialog] @{ InitialDirectory = "c:\" Filter = "rtf files (*.rtf)|*.rtf"; } $button = [System.Windows.Forms.Button] @{ Text = 'Seleccionar fichero .rtf' Location = [System.Drawing.Size]::new(80,100) AutoSize = $true BackColor = '#CCCC99' } $button.add_Click{ $ShowDialog.ShowDialog() convertir $ShowDialog.FileName } $form.Controls.Add($button) $form.ShowDialog() |