我有一個腳本,要求用戶使用Windows富文本框窗體輸入信息,每條信息都輸入到不同的行上,然後腳本添加信息到一個文本文件,但我希望它通過一個新的行分開信息。下面是我使用的代碼:目前是將信息作爲一段文本添加,沒有任何空格或行。任何幫助,將不勝感激輸出到文本文件時在新行上設置內容
cls
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Till's to Update"
$objForm.Size = New-Object System.Drawing.Size(300,550)
$objForm.StartPosition = "CenterScreen"
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(75,480)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.Add_Click({$x=$RichTextBox.Text;$objForm.Close()})
$objForm.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(150,480)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Cancel"
$CancelButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CancelButton)
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = "Please enter information:"
$objForm.Controls.Add($objLabel)
$RichTextBox = New-Object System.Windows.Forms.richtextbox
$RichTextBox.Location = New-Object System.Drawing.Size(10,80)
$RichTextBox.Size = New-Object System.Drawing.Size(260,320)
$objForm.Controls.Add($RichTextBox)
$objForm.Topmost = $True
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
$x
Set-Content -Value `n$x`n -Path c:\Computers.txt
你是一個傳奇,我開車我自己瘋狂試圖去解決它。多謝,夥計 – Kam0106