예제 #1
0
        public override void Run(bool runChildren)
        {
            string filename = FileName.Convert(this);

            if (string.IsNullOrEmpty(filename))
            {
                filename = GetText();
            }
            if (string.IsNullOrEmpty(filename))
            {
                ReportManage.ErrEmptyPropertyName(this, nameof(FileName));
                return;
            }
            if (System.IO.File.Exists(filename) == false)
            {
                ReportManage.ErrReport(this, "File「" + filename + "」は存在しません");
                return;
            }
            try
            {
                SetText(System.IO.File.ReadAllText(filename));
            }
            catch (Exception ex)
            {
                ReportManage.ErrReport(this, filename + "を開くのに失敗しました" + ex.Message);
                return;
            }

            base.Run(runChildren);
        }
예제 #2
0
        public override void Run(bool runChildren)
        {
            string filename = this.GetFileName();

            if (string.IsNullOrEmpty(filename))
            {
                ReportManage.ErrEmptyPropertyName(this, nameof(FileName));
                return;
            }
            if (System.IO.File.Exists(filename) == false)
            {
                ReportManage.ErrReport(this, "File「" + filename + "」は存在しません");
                return;
            }
            try
            {
                if (readEnd)
                {
                    string t = System.IO.File.ReadAllText(filename);
                    System.IO.StringReader sr   = new System.IO.StringReader(t);
                    List <string>          list = new List <string>();
                    while (sr.Peek() > -1)
                    {
                        string line = sr.ReadLine();
                        if (line.Length > 0)
                        {
                            list.Add(line);
                        }
                    }
                    sr.Close();
                    base.RunChildrenForArray(runChildren, list);
                }
                else
                {
                    var lines = System.IO.File.ReadLines(filename);
                    if (skip > 0)
                    {
                        lines = lines.Skip(skip);
                    }
                    base.RunChildrenForArray(runChildren, lines);
                }
            }
            catch (Exception ex)
            {
                ReportManage.ErrReport(this, FileName + "を開くのに失敗しました" + ex.Message);
            }
        }