Weben_CMS专用代码生成器/Code/GenerateCode_WeiBen_CMS.csproj | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Weben_CMS专用代码生成器/Code/MainForm.Designer.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Weben_CMS专用代码生成器/Code/MainForm.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Weben_CMS专用代码生成器/Code/Utility/FileHelper.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Weben_CMSרÓôúÂëÉú³ÉÆ÷/Code/GenerateCode_WeiBen_CMS.csproj
@@ -273,6 +273,7 @@ <DependentUpon>MainForm.cs</DependentUpon> </Compile> <Compile Include="Utility\StructStrHelper.cs" /> <Compile Include="Utility\FileHelper.cs" /> <Compile Include="Utility\TextHelper.cs" /> <EmbeddedResource Include="Properties\Resources.resx"> <Generator>ResXFileCodeGenerator</Generator> Weben_CMSרÓôúÂëÉú³ÉÆ÷/Code/MainForm.Designer.cs
@@ -79,13 +79,14 @@ this.tb_FilePath = new System.Windows.Forms.TextBox(); this.btn_SelectFile = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); this.ck_IsDeletefile = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // btnPath // this.btnPath.Location = new System.Drawing.Point(453, 723); this.btnPath.Location = new System.Drawing.Point(425, 720); this.btnPath.Name = "btnPath"; this.btnPath.Size = new System.Drawing.Size(97, 23); this.btnPath.TabIndex = 1; @@ -564,11 +565,25 @@ this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click_1); // // ck_IsDeletefile // this.ck_IsDeletefile.AutoSize = true; this.ck_IsDeletefile.Checked = true; this.ck_IsDeletefile.CheckState = System.Windows.Forms.CheckState.Checked; this.ck_IsDeletefile.Location = new System.Drawing.Point(561, 724); this.ck_IsDeletefile.Name = "ck_IsDeletefile"; this.ck_IsDeletefile.Size = new System.Drawing.Size(192, 16); this.ck_IsDeletefile.TabIndex = 50; this.ck_IsDeletefile.Text = "çæåæ¯å¦å æ¸ çæä»¶å¤¹çæä»¶"; this.ck_IsDeletefile.UseVisualStyleBackColor = true; this.ck_IsDeletefile.CheckedChanged += new System.EventHandler(this.ck_IsDeletefile_CheckedChanged); // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1402, 831); this.Controls.Add(this.ck_IsDeletefile); this.Controls.Add(this.button1); this.Controls.Add(this.btn_SelectFile); this.Controls.Add(this.tb_FilePath); @@ -645,6 +660,7 @@ private System.Windows.Forms.Button btn_SelectFile; private System.Windows.Forms.Button button1; private System.Windows.Forms.Label label1; private System.Windows.Forms.CheckBox ck_IsDeletefile; } } Weben_CMSרÓôúÂëÉú³ÉÆ÷/Code/MainForm.cs
@@ -283,6 +283,13 @@ //CreateModelFile(columnList, tableName, filePrefixName, wcf_NameSpacePath, createPerson, chinaComment, entityName, modulelogo); //CreateModelParamFile(columnList, tableName, filePrefixName, wcf_NameSpacePath, createPerson, chinaComment, entityName, modulelogo); genCodeRootPath = tbPath.Text + @"\" + tb_WCF_NameSpacePath.Text.Trim(); //æ¯å¦è¦äºå æ¸ çæä»¶å¤¹ if (this.ck_IsDeletefile.Checked) { FileHelper.ClearFolder(genCodeRootPath); // éå½å é¤ } //var webFolerPath = (tb_WCF_NameSpacePath.Text.Trim() + "_Web").ToLower(); var webFolerPath = _tb_VueRootFolerName; #region å®ä½ç±» @@ -825,5 +832,10 @@ { this.tb_FilePath.Text = ""; } private void ck_IsDeletefile_CheckedChanged(object sender, EventArgs e) { } } } Weben_CMSרÓôúÂëÉú³ÉÆ÷/Code/Utility/FileHelper.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,71 @@  using GenerateCode_GEBrilliantFactory; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace GenerateCode_GEBrilliantFactory { public class FileHelper { public static void DeleteAllContentsInFolder(string folderPath) { try { if (Directory.Exists(folderPath)) { // å 餿ææä»¶ååæä»¶å¤¹ï¼å æ¬åæä»¶å¤¹ä¸çæä»¶ï¼ foreach (string file in Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories)) { File.Delete(file); Console.WriteLine($"å·²å 餿件: {file}"); } // å 餿æåæä»¶å¤¹ï¼æ¤æ¶æä»¶å¤¹å·²ç©ºï¼å¯ä»¥å®å ¨å é¤ï¼ foreach (string dir in Directory.GetDirectories(folderPath, "*", SearchOption.AllDirectories)) { Directory.Delete(dir); // ä¸éè¦éå½ï¼å 为æä»¶å·²è¢«å é¤ Console.WriteLine($"å·²å 餿件夹: {dir}"); } Console.WriteLine($"æåæ¸ ç©ºæä»¶å¤¹ '{folderPath}' ä¸çææå 容ã"); } else { Console.WriteLine($"æä»¶å¤¹ä¸åå¨: {folderPath}"); } } catch (Exception ex) { Console.WriteLine($"å 餿件/æä»¶å¤¹æ¶åºé: {ex.Message}"); } } public static void ClearFolder(string folderPath) { try { if (Directory.Exists(folderPath)) { // å 餿ææä»¶ååæä»¶å¤¹ï¼å æ¬åæä»¶å¤¹ä¸çæä»¶ï¼ Directory.Delete(folderPath, true); // true 表示éå½å é¤ Directory.CreateDirectory(folderPath); // éæ°å建空æä»¶å¤¹ Console.WriteLine($"å·²æ¸ ç©ºå¹¶é建æä»¶å¤¹ '{folderPath}'ã"); } else { Console.WriteLine($"æä»¶å¤¹ä¸åå¨: {folderPath}"); } } catch (Exception ex) { Console.WriteLine($"æ¸ ç©ºæä»¶å¤¹æ¶åºé: {ex.Message}"); } } } }