Example #1
0
        private void LoadPreviewFile(string pathName)
        {
            Debug.WriteLine("LOAD " + pathName);

            try {
                using (StreamReader sr = new StreamReader(pathName, Encoding.UTF8)) {
                    char[] bigbuf = new char[PREVIEW_BUF_SIZE];
                    int    actual = sr.Read(bigbuf, 0, bigbuf.Length);
                    string str    = TextUtil.CharArrayToLineNumberedString(bigbuf);
                    if (actual < PREVIEW_BUF_SIZE)
                    {
                        previewTextBox.Text = str;
                    }
                    else
                    {
                        previewTextBox.Text = str + "\r\n" +
                                              Res.Strings.ERR_TOO_LARGE_FOR_PREVIEW;
                    }
                }
            } catch (Exception ex) {
                previewTextBox.Text = ex.ToString();
            }
        }