예제 #1
0
        private void Frm_ListBox_Load(object sender, EventArgs e)
        {
            string Tem_Path = "";
            string Tem_Name = "";

            ToolS_Mode03.Checked = true;
            this.Left            = FrmClass.Example_Play_Left;
            this.Top             = FrmClass.Example_Play_Top + FrmClass.Example_Play_Height;
            Cla_FrmClass.Format_ListV(listView_List);
            Cla_FrmClass.FrmInitialize(this);

            Cla_FrmClass.Format_ListN(listView_Fname);
            Tem_Dir  = Cla_FrmClass.UpAndDown_Dir(System.AppDomain.CurrentDomain.BaseDirectory);
            Tem_Path = Tem_Dir;
            Tem_Dir  = Tem_Dir + "\\默认.m3u";
            FrmClass.Example_ListNameDir = Tem_Dir;
            if (File.Exists(Tem_Dir))
            {
                Cla_FrmClass.m3uRead(Tem_Dir);
                if (FrmClass.AList.Count > 1)
                {
                    Cla_FrmClass.ListAddFile(listView_Fname, listView_List, FrmClass.AList);
                }
            }
            else
            {
                Cla_FrmClass.m3uCreate(Tem_Dir);
            }

            Cla_FrmClass.Data_List(listView_Fname, "默认", Tem_Dir);
            FrmClass.Example_ListNameNark     = 0;
            listView_Fname.Items[0].BackColor = Color.DarkGreen;
            string        Tem_Play = "";
            DirectoryInfo dir      = new DirectoryInfo(Tem_Path);

            FileSystemInfo[] files = dir.GetFileSystemInfos();//获取文件夹中所有文件和文件夹
            //对单个FileSystemInfo进行判断,如果是文件夹则进行递归操作
            foreach (FileSystemInfo FSys in files)
            {
                FileInfo file = FSys as FileInfo;
                if (file != null)
                {
                    Tem_Name = file.DirectoryName + "\\" + file.Name;
                    Tem_Name = Tem_Name.Substring(Tem_Name.LastIndexOf(Convert.ToChar(".")) + 1, Tem_Name.Length - Tem_Name.LastIndexOf(Convert.ToChar(".")) - 1);
                    if (Tem_Name.ToLower() == "m3u")
                    {
                        if (file.Name.Substring(0, file.Name.Length - 4) != "默认")
                        {
                            Tem_Play = file.DirectoryName + "\\" + file.Name;
                            Cla_FrmClass.Data_List(listView_Fname, file.Name.Substring(0, file.Name.Length - 4), Tem_Play);
                        }
                    }
                }
            }
        }