Beispiel #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.FileName         = "default.txt";
            ofd.InitialDirectory = @"C:\";
            ofd.Filter           =
                "テキストファイル(*.txt)|*.txt|すべてのファイル(*.*)|*.*";
            ofd.FilterIndex      = 2;
            ofd.Title            = "開くファイルを選択してください";
            ofd.RestoreDirectory = true;
            ofd.CheckFileExists  = true;
            ofd.CheckPathExists  = true;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                FullText = File.ReadAllText(ofd.FileName, System.Text.Encoding.GetEncoding("Shift_JIS"));
            }
            else
            {
                this.Close();
            }

            FormatText = System.Text.RegularExpressions.Regex.Replace(
                FullText.Replace("\r", "").Replace("\n", "").Replace(" ", ""),
                @"《.*?》 ", "");

            //MessageBox.Show(FormatText);

            TextQ = new Queue <string>(FormatText.Split(' '));
        }