Row break Code Editor?

PSU 2.3.1

Hi,
I’m reading in content from a file to Code Editor and now I’m wondering if it’s possible to do the break on the end of the line so it get a new row? For now it do read in the file as one big line.
Here is my code:

            New-UDGrid -Spacing '1' -Container -Content {
                #      $GetInstallationlogg = [System.IO.File]::ReadLines("PathTOLog\LogFile.log")
                if ([string]::IsNullOrEmpty($GetInstallationlogg)) {
                    New-UDGrid -Item -Size 12 -Content {
                        New-UDAlert -Severity 'error' -Text "Kunde inte läsa ut loggfilen!"
                    }
                }
                else {
                    New-UDGrid -Item -Size 12 -Content {
                        Add-UDElement -ParentId 'InstallationLogFileEditor' -Content {
                            [System.IO.File]::ReadLines("PathTOLog\LogFile.log")
                        }
                        New-UDCodeEditor -Id 'InstallationLogFileEditor' -ReadOnly -Height 450 #-Code "$GetInstallationlogg"
                    }
                }
            }

@adam

@adam any ide? I need it to load the content from a log file and I badly need it to bee readable.

I will take a peek at this tomorrow. I need to play with the component.

The problem is that you need to use ReadAllText rather than ReadAllLines. ReadAllText returns a single string while ReadAllLines returns an array of strings which are then concatenated together to form the single string without line breaks.

New-UDCodeEditor -ReadOnly -Height 450 -Code ([System.IO.File]::ReadAllText("C:\Users\adamr\Desktop\login.1831227996.txt"))

1 Like