我有進口的文本文件和一個按鈕被點擊Powershell的GUI導入的文本文件中缺少換行符/回車
但即使文本文件包含每行,當一個條目時顯示在一個文本框,一個PowerShell GUI它就會顯示在文本框中它是所有在一行...
文本文件看起來像這個 -
但是,當我導入它看起來像這 -
這是代碼我using-
$button_hosts = New-Object system.windows.Forms.Button
$button_hosts.Text = "Hosts"
$button_hosts.Width = 60
$button_hosts.Height = 25
$button_hosts.location = new-object system.drawing.point(20,55)
$button_hosts.Font = "Microsoft Sans Serif,10"
$mydocs = [Environment]::GetFolderPath('MyDocuments')
$button_hosts.Add_Click({
$textBox_hosts.Text = Get-Filename "$mydocs" txt
$textBox_hostlist.Text = Get-Content $textBox_hosts.Text
})
$GUI.controls.Add($button_hosts)
不知道如何得到它顯示的一樣嗎?我不能添加任何額外的數據到txt文件,因爲它是從另一個程序的輸出
在Notepad ++中,進入'View'>'Show Symbol'>'Show End of Line'並更新截圖。 – gms0ulman
試試'$ textBox_hostlist.Text = Get-Content $ textBox_hosts.Text | OUT-String'。 –