Exemplo n.º 1
0
 private void MenuItem_Build_Click(object sender, EventArgs e)
 {
     if (Select_Floder != null && Select_Floder != "")
     {
         Select_Dir = new DirectoryInfo(Select_Floder);
         if (Select_Dir.ToString() == Select_Dir.Root.ToString())
         {
             Console.WriteLine("It is a Driver!");
             Select_Dri = new DriveInfo(Select_Dir.Root.Name);
             XElement dirXml   = Select_Dri.LToXml();//显示所有文件
             string   XML_Name = Select_Dri.VolumeLabel + Select_Dri.Name.Substring(0, 1) + "(" + (Select_Dri.TotalSize / 1024 / 1024 / 1024).ToString() + "G)";
             string   XML_Path = Config_INI.ReadString("XML", "XML_Build_Path", "");
             if (XML_Path == null || XML_Path == "")
             {
                 MessageBox.Show("ERROR 101 :\nDO NOT Find XML_Build_Path in XML!");
                 return;
             }
             string XML_FullPath = XML_Path + XML_Name + ".xml";
             if (File.Exists(XML_FullPath))
             {
                 //MessageBox.Show("Existed!So Rewrite!");
                 this.StatusLabel1.Text = "Existed!So Rewrite.";
                 File.Delete(XML_FullPath);
                 dirXml.Save(XML_FullPath);
                 this.StatusLabel2.Text = "Created.(Driver)";
             }
             else
             {
                 dirXml.Save(XML_FullPath);
                 this.StatusLabel2.Text = "Created.(Driver)";
             }
         }
         else
         {
             XElement dirXml   = Select_Dir.LToXml();//显示所有文件
             string   XML_Name = Select_Dir.Name;
             string   XML_Path = Config_INI.ReadString("XML", "XML_Build_Path", "");
             if (XML_Path == null || XML_Path == "")
             {
                 MessageBox.Show("ERROR 101 :\nDO NOT Find XML_Build_Path in XML!");
                 return;
             }
             string XML_FullPath = XML_Path + XML_Name + ".xml";
             if (File.Exists(XML_FullPath))
             {
                 //MessageBox.Show("Existed!So Rewrite!");
                 this.StatusLabel1.Text = "Existed!So Rewrite.";
                 File.Delete(XML_FullPath);
                 dirXml.Save(XML_FullPath);
                 this.StatusLabel2.Text = "Created.(Floder)";
             }
             else
             {
                 dirXml.Save(XML_FullPath);
                 this.StatusLabel2.Text = "Created.(Floder)";
             }
         }
     }
     else
     {
         this.StatusLabel1.Text = "Path is NULL!";
     }
 }