private static StringBuilder Zapis = new StringBuilder(string.Empty); private static ManagementObjectSearcher GetMonitor = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_DesktopMonitor"); foreach (ManagementObject queryObj in GetMonitor.Get()) { Zapis.AppendFormat("Разрешение экрана:" + string.Format(queryObj["ScreenWidth"] + "x" + queryObj["ScreenHeight"])); } After writing to the file, this line appears:
Screen resolution: x
Разрешение экрана: 1920x1080
An extra line is displayed 1st - Разрешение экрана: x How to remove this line? }
format-function, if you do not use them for their intended purpose. Зы2: check the presence of the value before adding and filtering.if(queryObj["ScreenWidth"]){zapis.append (...); } - teranformatused for the worst case) I tried the same thing without it :( But constantly getting the first line with an emptyx- GooliveRУниверсальный монитор PnP` - GooliveR