Esempio n. 1
0
        private void ReadLineFromConsole()
        {
            // Magic number of 26608 was arrived at experimentally.
            // ReadConsole fails if you try to read more than that many characters.
            char[] buff        = new char[26608];
            int    charsToRead = buff.Length;
            int    charsRead   = 0;

            if (!WinCon.ReadConsole(handle, buff, charsToRead, ref charsRead, IntPtr.Zero))
            {
                int err = Marshal.GetLastWin32Error();
                throw new IOException("Error reading console input buffer", err);
            }
            sBuffer.Length = 0;
            sBuffer.Append(buff, 0, charsRead);
        }