コード例 #1
0
        private void Dgvadd(string [] path)
        {
            string  pic  = "";
            string  pan1 = "";
            string  pan2 = "";
            string  pan3 = "";
            Readtxt rdt  = new Readtxt();

            foreach (string p in path)
            {
                if (p.Contains(".jpg"))
                {
                    if (p.Contains("特写"))
                    {
                        pic = p;
                    }
                    else if (p.Contains("闯入1"))
                    {
                        pan1 = p;
                    }
                    else if (p.Contains("闯入2"))
                    {
                        pan2 = p;
                    }
                    else if (p.Contains("闯入3"))
                    {
                        pan3 = p;
                    }
                }
                else if (p.Contains("result.txt"))
                {
                    Readtxt(p, ref rdt);
                }
            }
            DataGridViewRow dr = new DataGridViewRow();

            dr.CreateCells(dataGridView);
            dr.Cells[0].Value = Image.FromFile(pic);
            dr.Cells[1].Value = Image.FromFile(pan1);
            dr.Cells[2].Value = Image.FromFile(pan2);
            dr.Cells[3].Value = Image.FromFile(pan3);
            dr.Cells[4].Value = rdt.gender;
            dr.Cells[5].Value = rdt.age;
            dr.Cells[6].Value = rdt.time;
            dr.Height         = 56;
            dataGridView.Rows.Insert(0, dr);
        }
コード例 #2
0
        private void Readtxt(string path, ref Readtxt rt)//
        {
            StreamReader sr = new StreamReader(path);
            string       line;
            string       txt = "";

            while ((line = sr.ReadLine()) != null)
            {
                txt += line;
            }
            int i = txt.IndexOf("性别:") + 3;
            int j = txt.IndexOf("年龄:");

            rt.gender = txt.Substring(i, j - i);
            i         = txt.IndexOf("年龄:") + 3;
            j         = txt.IndexOf("时间:");
            rt.age    = txt.Substring(i, j - i);
            i         = txt.IndexOf("时间:") + 3;
            j         = txt.IndexOf("位置信息:");
            DateTime dt = DateTime.Now;

            dt      = Convert.ToDateTime(txt.Substring(i, j - i));
            rt.time = dt.ToLongTimeString().ToString();
        }