Browse Source

chore: clean

HOME 2 years ago
parent
commit
bb6b478360
1 changed files with 10 additions and 11 deletions
  1. 10 11
      FileNameCharsetConvert/MainForm.cs

+ 10 - 11
FileNameCharsetConvert/MainForm.cs

@@ -26,13 +26,12 @@ namespace FileNameCharsetConvert
         {
             lvMain.Items.Clear();
 
-            string[] files = Directory.GetFiles(txtFolder.Text, "*.*", System.IO.SearchOption.AllDirectories);
+            var files = Directory.GetFiles(txtFolder.Text, "*.*", System.IO.SearchOption.AllDirectories);
 
-            for (int i = 0; i < files.Length; i++)
+            for (var i = 0; i < files.Length; i++)
             {
                 proc.Value = (int)(i * 1.0f / files.Length * 100);
-                ListViewItem lvi = new ListViewItem();
-                lvi.Text = files[i];
+                var lvi = new ListViewItem { Text = files[i] };
                 lvi.SubItems.Add("               ");
                 lvi.SubItems.Add("未转换");
 
@@ -46,14 +45,14 @@ namespace FileNameCharsetConvert
 
         private void btnConvert_Click(object sender, EventArgs e)
         {
-            EncodingInfo enci = (EncodingInfo)cmbEncoding.SelectedItem;
-            Encoding enc = enci.GetEncoding();
-            Encoding def = Encoding.Default;
+            var enci = (EncodingInfo)cmbEncoding.SelectedItem;
+            var enc = enci.GetEncoding();
+            var def = Encoding.Default;
 
-            for (int i = 0; i < lvMain.Items.Count; i++)
+            for (var i = 0; i < lvMain.Items.Count; i++)
             {
                 proc.Value = (int)(i * 1.0f / lvMain.Items.Count * 100);
-                ListViewItem item = lvMain.Items[i];
+                var item = lvMain.Items[i];
                 item.SubItems[1].Text = enc.GetString(def.GetBytes(item.Text));
                 item.SubItems[2].Text = "已转换,未应用";
             }
@@ -71,9 +70,9 @@ namespace FileNameCharsetConvert
 
         private void btnApplySelection_Click(object sender, EventArgs e)
         {
-            for (int i = 0; i < lvMain.SelectedItems.Count; i++)
+            for (var i = 0; i < lvMain.SelectedItems.Count; i++)
             {
-                ListViewItem lvi = lvMain.SelectedItems[i];
+                var lvi = lvMain.SelectedItems[i];
 
                 try
                 {