Beispiel #1
0
        }//打开双击文件夹

        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //在此处设断点,发现点击不同的Item后,此事件居然执行了2次
            //第一次是取消当前Item选中状态,导致整个ListView的SelectedIndices变为 空集
            //第二次才将新选中的Item设置为选中状态,SelectedIndices变为 非空集
            //如果不加listview.SelectedIndices.Count>0判断,将导致获取listview.Items[]索引超界的异常
            if (listView1.SelectedIndices.Count > 0)
            {
                int c = listView1.SelectedIndices[0];                                          //获得选中项的索引
                currentFolder = listView1.Items[c].SubItems[1].Text + listView1.Items[c].Text; //组装绝对地址

                int    pos_int = listView1.Items[currentRowIndex].Text.LastIndexOf("】");
                string tmp_str = listView1.Items[currentRowIndex].SubItems[1].Text + listView1.Items[currentRowIndex].Text +
                                 @"\" + listView1.Items[currentRowIndex].Text.Remove(0, pos_int + 1) + ".xml";//组装XML文件绝对地址
                if (File.Exists(tmp_str))
                {
                    XML_Class x = new XML_Class();
                    pd = x.ReadXml(tmp_str);
                }
                else
                {
                    pd = null;
                }
                if (pd != null)
                {
                    tmp_str = listView1.Items[currentRowIndex].Text.ToString();
                    tmp_str = pd.FolderName(tmp_str);
                }
                ShowDetailsOnDV(pd);
            }
        }
Beispiel #2
0
        public static ProjectDetails getPD(string pPath)
        {
            ProjectDetails rtPD = new Folders.ProjectDetails();

            if (File.Exists(pPath))
            {
                XML_Class x = new XML_Class();
                rtPD = x.ReadXml(pPath);
            }
            else
            {
                rtPD = null;
            }
            return(rtPD);
        }