C#實現(xiàn)批量更改文件名稱大小寫或擴展名
更新時間:2022年12月26日 08:55:29 作者:芝麻粒兒
這篇文章主要為大家詳細(xì)介紹了如何利用C#實現(xiàn)批量更改文件名稱大小寫或擴展名的功能,文中的示例代碼講解詳細(xì),對我們學(xué)習(xí)C#有一定的幫助,感興趣的小伙伴可以跟隨小編一起了解一下
實踐過程
效果
代碼
public partial class Form1 : Form { public Form1() { InitializeComponent(); } string[] files;//選擇文件的集合 FileInfo fi;//創(chuàng)建一個FileInfo對象,用于獲取文件信息 string[] lvFiles=new string[7];//向控件中添加的行信息 Thread td;//處理批量更名方法的線程 private void 添加文件ToolStripMenuItem_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { listView1.GridLines = true; listView1.Items.Clear(); files = openFileDialog1.FileNames; for (int i = 0; i < files.Length; i++) { string path = files[i].ToString(); fi = new FileInfo(path); string name = path.Substring(path.LastIndexOf("\\") + 1, path.Length - 1 - path.LastIndexOf("\\")); string ftype = path.Substring(path.LastIndexOf("."), path.Length - path.LastIndexOf(".")); string createTime = fi.CreationTime.ToShortDateString(); double a = Convert.ToDouble(Convert.ToDouble(fi.Length) / Convert.ToDouble(1024)); string fsize = a.ToString("0.0")+" KB"; lvFiles[0] = name; lvFiles[1] = name; lvFiles[2] = ftype; lvFiles[3] = createTime; lvFiles[4] = path.Remove(path.LastIndexOf("\\") + 1); lvFiles[5] = fsize; ListViewItem lvi = new ListViewItem(lvFiles); lvi.UseItemStyleForSubItems = false; lvi.SubItems[1].BackColor = Color.AliceBlue; listView1.Items.Add(lvi); } tsslSum.Text = listView1.Items.Count.ToString(); } } bool flag = true; private void 總在最前ToolStripMenuItem_Click(object sender, EventArgs e) { if (flag) { 總在最前ToolStripMenuItem.Checked = true; this.TopMost = true; flag = false; } else { 總在最前ToolStripMenuItem.Checked = false; this.TopMost = false; flag = true; } } private void radioButton1_CheckedChanged(object sender, EventArgs e)//文件名大寫 { if (listView1.Items.Count > 0) { if (radioButton1.Checked) { for (int i = 0; i < listView1.Items.Count; i++) { string name = listView1.Items[i].SubItems[1].Text; string name1 = name.Remove(name.LastIndexOf(".")); string newName = name.Replace(name1,name1.ToUpper()); listView1.Items[i].SubItems[1].Text = newName; } } } } private void radioButton2_CheckedChanged(object sender, EventArgs e)//文件名小寫 { if (listView1.Items.Count > 0) { if (radioButton2.Checked) { for (int i = 0; i < listView1.Items.Count; i++) { string name = listView1.Items[i].SubItems[1].Text; string name1 = name.Remove(name.LastIndexOf(".")); string newName = name.Replace(name1, name1.ToLower()); listView1.Items[i].SubItems[1].Text = newName; } } } } private void radioButton3_CheckedChanged(object sender, EventArgs e)//第一個字母大寫 { if (listView1.Items.Count > 0) { if (radioButton3.Checked) { for (int i = 0; i < listView1.Items.Count; i++) { string name = listView1.Items[i].SubItems[1].Text; string name1 = name.Substring(0,1); string name2 = name.Substring(1); string newName = name1.ToUpper() + name2; listView1.Items[i].SubItems[1].Text = newName; } } } } private void radioButton4_CheckedChanged(object sender, EventArgs e)//擴展名大寫 { if (listView1.Items.Count > 0) { if (radioButton4.Checked) { for (int i = 0; i < listView1.Items.Count; i++) { string name = listView1.Items[i].SubItems[1].Text; string name1 = name.Substring(name.LastIndexOf("."), name.Length - name.LastIndexOf(".")); string newName = name.Replace(name1, name1.ToUpper()); listView1.Items[i].SubItems[1].Text = newName; } } } } private void radioButton5_CheckedChanged(object sender, EventArgs e) { if (listView1.Items.Count > 0) { if (radioButton5.Checked) { for (int i = 0; i < listView1.Items.Count; i++) { string name = listView1.Items[i].SubItems[1].Text; string name1 = name.Substring(name.LastIndexOf("."), name.Length - name.LastIndexOf(".")); string newName = name.Replace(name1, name1.ToLower()); listView1.Items[i].SubItems[1].Text = newName; } } } } bool IsOK = false;//判斷是否應(yīng)用了模板 private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)//選擇模板的下拉框 { int k = (int)nuStart.Value; if (comboBox2.Text != "") { txtTemplate.Text = comboBox2.Text.Remove(comboBox2.Text.LastIndexOf("_")); int B = comboBox2.SelectedIndex; switch (B) { case 0: if (listView1.Items.Count > 0) { for (int i = 0; i < listView1.Items.Count; i++) { string name = listView1.Items[i].SubItems[1].Text; string name1 = name.Remove(name.LastIndexOf(".")); string name2 = "pic_" + k.ToString(); k = k + (int)nuAdd.Value; string newName = name.Replace(name1, name2); listView1.Items[i].SubItems[1].Text = newName; } IsOK = true; } break; case 1: if (listView1.Items.Count > 0) { for (int i = 0; i < listView1.Items.Count; i++) { string name = listView1.Items[i].SubItems[1].Text; string name1 = name.Remove(name.LastIndexOf(".")); string name2 = "file_" + k.ToString(); k = k +(int) nuAdd.Value; string newName = name.Replace(name1,name2); listView1.Items[i].SubItems[1].Text = newName; } IsOK = true; } break; } } } private void StartNumAndAdd()//設(shè)置起始數(shù)字和增量值 { int k = (int)nuStart.Value; if (comboBox2.Text != "") { if (listView1.Items.Count > 0) { for (int i = 0; i < listView1.Items.Count; i++) { string name = listView1.Items[i].SubItems[1].Text; string name1 = name.Remove(name.LastIndexOf(".")); string name2 = name1.Remove(name.LastIndexOf("_")+1)+k.ToString(); k = k + (int)nuAdd.Value; string newName = name.Replace(name1, name2); listView1.Items[i].SubItems[1].Text = newName; } IsOK = true; } } } private void nuStart_ValueChanged(object sender, EventArgs e)//選擇起始數(shù)字 { StartNumAndAdd(); } private void nuAdd_ValueChanged(object sender, EventArgs e)//選擇增量值 { StartNumAndAdd(); } private void txtTemplate_TextChanged(object sender, EventArgs e)//更換模板樣式 { if (listView1.Items.Count > 0) { if (IsOK&&txtTemplate.Text.Trim()!=""&&comboBox2.Text!="") { for (int i = 0; i < listView1.Items.Count; i++) { string name = listView1.Items[i].SubItems[1].Text; string name1 = name.Remove(name.LastIndexOf("_") + 1); string newName = name.Replace(name1, txtTemplate.Text.Trim() + "_"); listView1.Items[i].SubItems[1].Text = newName; } } } } private void ChangeName() { int flag = 0; try { toolStripProgressBar1.Minimum = 0; toolStripProgressBar1.Maximum = listView1.Items.Count - 1; for (int i = 0; i < listView1.Items.Count; i++) { string path = listView1.Items[i].SubItems[4].Text; string sourcePath = path + listView1.Items[i].SubItems[0].Text; string newPath = path + listView1.Items[i].SubItems[1].Text; File.Copy(sourcePath, newPath); File.Delete(sourcePath); toolStripProgressBar1.Value = i; listView1.Items[i].SubItems[0].Text = listView1.Items[i].SubItems[1].Text; listView1.Items[i].SubItems[6].Text = "√成功"; } } catch(Exception ex) { flag++; MessageBox.Show(ex.Message); } finally { tsslError.Text = flag.ToString() + " 個錯誤"; } } private void 更名ToolStripMenuItem_Click(object sender, EventArgs e)//開始批量更名 { if (listView1.Items.Count > 0) { for (int i = 0; i < listView1.Items.Count; i++) { listView1.Items[i].SubItems[6].Text = ""; } tsslError.Text = ""; td = new Thread(new ThreadStart(ChangeName)); td.Start(); } } private void Form1_Load(object sender, EventArgs e) { CheckForIllegalCrossThreadCalls = false; } private void 導(dǎo)出文件列表ToolStripMenuItem_Click(object sender, EventArgs e) { if (saveFileDialog1.ShowDialog() == DialogResult.OK) { StreamWriter sw; string txt = ""; string path = saveFileDialog1.FileName; for (int i = 0; i < listView1.Items.Count; i++) { txt = listView1.Items[i].SubItems[0].Text + " " + listView1.Items[i].SubItems[1].Text; sw = File.AppendText(path); sw.WriteLine(txt); sw.Close(); } } } private void 退出ToolStripMenuItem_Click(object sender, EventArgs e) { Application.Exit(); } private static string TraditionalChineseToSimplifiedChinese(string str)//繁體轉(zhuǎn)簡體 { return (Microsoft.VisualBasic.Strings.StrConv(str,Microsoft.VisualBasic.VbStrConv.SimplifiedChinese,0)); } private static string SimplifiedChineseToTraditionalChinese(string str)//簡體轉(zhuǎn)繁體 { return (Microsoft.VisualBasic.Strings.StrConv(str as string ,Microsoft.VisualBasic.VbStrConv.TraditionalChinese,0)); } private void 繁體轉(zhuǎn)簡體ToolStripMenuItem_Click(object sender, EventArgs e) { if (listView1.Items.Count > 0) { for (int i = 0; i < listView1.Items.Count; i++) { string name = listView1.Items[i].SubItems[1].Text; string name1 = TraditionalChineseToSimplifiedChinese(name); listView1.Items[i].SubItems[1].Text = name1; } } } private void 簡體轉(zhuǎn)繁體ToolStripMenuItem_Click(object sender, EventArgs e) { if (listView1.Items.Count > 0) { for (int i = 0; i < listView1.Items.Count; i++) { string name = listView1.Items[i].SubItems[1].Text; string name1 = SimplifiedChineseToTraditionalChinese(name); listView1.Items[i].SubItems[1].Text = name1; } } } private void Form1_FormClosed(object sender, FormClosedEventArgs e) { if (td != null) { td.Abort(); } } private void 關(guān)于ToolStripMenuItem_Click(object sender, EventArgs e) { AboutBox1 ab = new AboutBox1(); ab.ShowDialog(); } }
partial class Form1 { /// <summary> /// 必需的設(shè)計器變量。 /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// 清理所有正在使用的資源。 /// </summary> /// <param name="disposing">如果應(yīng)釋放托管資源,為 true;否則為 false。</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows 窗體設(shè)計器生成的代碼 /// <summary> /// 設(shè)計器支持所需的方法 - 不要 /// 使用代碼編輯器修改此方法的內(nèi)容。 /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.文件ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.添加文件ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.總在最前ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.導(dǎo)出文件列表ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.退出ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.更名PToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.更名ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.繁體轉(zhuǎn)簡體ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.簡體轉(zhuǎn)繁體ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.幫助HToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.關(guān)于ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); this.tsslSum = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel3 = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar(); this.tsslError = new System.Windows.Forms.ToolStripStatusLabel(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.radioButton5 = new System.Windows.Forms.RadioButton(); this.radioButton4 = new System.Windows.Forms.RadioButton(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.radioButton3 = new System.Windows.Forms.RadioButton(); this.radioButton2 = new System.Windows.Forms.RadioButton(); this.radioButton1 = new System.Windows.Forms.RadioButton(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.txtTemplate = new System.Windows.Forms.TextBox(); this.label5 = new System.Windows.Forms.Label(); this.nuAdd = new System.Windows.Forms.NumericUpDown(); this.label4 = new System.Windows.Forms.Label(); this.nuStart = new System.Windows.Forms.NumericUpDown(); this.label3 = new System.Windows.Forms.Label(); this.comboBox2 = new System.Windows.Forms.ComboBox(); this.label2 = new System.Windows.Forms.Label(); this.listView1 = new System.Windows.Forms.ListView(); this.columnHeader1 = new System.Windows.Forms.ColumnHeader(); this.columnHeader2 = new System.Windows.Forms.ColumnHeader(); this.columnHeader3 = new System.Windows.Forms.ColumnHeader(); this.columnHeader4 = new System.Windows.Forms.ColumnHeader(); this.columnHeader5 = new System.Windows.Forms.ColumnHeader(); this.columnHeader6 = new System.Windows.Forms.ColumnHeader(); this.columnHeader7 = new System.Windows.Forms.ColumnHeader(); this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.groupBox2.SuspendLayout(); this.groupBox1.SuspendLayout(); this.tabPage2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nuAdd)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nuStart)).BeginInit(); this.SuspendLayout(); // // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.文件ToolStripMenuItem, this.更名PToolStripMenuItem, this.幫助HToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; this.menuStrip1.Size = new System.Drawing.Size(597, 24); this.menuStrip1.TabIndex = 0; this.menuStrip1.Text = "menuStrip1"; // // 文件ToolStripMenuItem // this.文件ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.添加文件ToolStripMenuItem, this.總在最前ToolStripMenuItem, this.導(dǎo)出文件列表ToolStripMenuItem, this.退出ToolStripMenuItem}); this.文件ToolStripMenuItem.Name = "文件ToolStripMenuItem"; this.文件ToolStripMenuItem.Size = new System.Drawing.Size(59, 20); this.文件ToolStripMenuItem.Text = "文件(&F)"; // // 添加文件ToolStripMenuItem // this.添加文件ToolStripMenuItem.Image = global::FileBatchChangeName.Properties.Resources.圖標(biāo)__220_; this.添加文件ToolStripMenuItem.Name = "添加文件ToolStripMenuItem"; this.添加文件ToolStripMenuItem.Size = new System.Drawing.Size(142, 22); this.添加文件ToolStripMenuItem.Text = "添加文件..."; this.添加文件ToolStripMenuItem.Click += new System.EventHandler(this.添加文件ToolStripMenuItem_Click); // // 總在最前ToolStripMenuItem // this.總在最前ToolStripMenuItem.Name = "總在最前ToolStripMenuItem"; this.總在最前ToolStripMenuItem.Size = new System.Drawing.Size(142, 22); this.總在最前ToolStripMenuItem.Text = "總在最前"; this.總在最前ToolStripMenuItem.Click += new System.EventHandler(this.總在最前ToolStripMenuItem_Click); // // 導(dǎo)出文件列表ToolStripMenuItem // this.導(dǎo)出文件列表ToolStripMenuItem.Image = global::FileBatchChangeName.Properties.Resources.圖標(biāo)__166_; this.導(dǎo)出文件列表ToolStripMenuItem.Name = "導(dǎo)出文件列表ToolStripMenuItem"; this.導(dǎo)出文件列表ToolStripMenuItem.Size = new System.Drawing.Size(142, 22); this.導(dǎo)出文件列表ToolStripMenuItem.Text = "導(dǎo)出文件列表"; this.導(dǎo)出文件列表ToolStripMenuItem.Click += new System.EventHandler(this.導(dǎo)出文件列表ToolStripMenuItem_Click); // // 退出ToolStripMenuItem // this.退出ToolStripMenuItem.Image = global::FileBatchChangeName.Properties.Resources.圖標(biāo)__99_; this.退出ToolStripMenuItem.Name = "退出ToolStripMenuItem"; this.退出ToolStripMenuItem.Size = new System.Drawing.Size(142, 22); this.退出ToolStripMenuItem.Text = "退出"; this.退出ToolStripMenuItem.Click += new System.EventHandler(this.退出ToolStripMenuItem_Click); // // 更名PToolStripMenuItem // this.更名PToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.更名ToolStripMenuItem, this.繁體轉(zhuǎn)簡體ToolStripMenuItem, this.簡體轉(zhuǎn)繁體ToolStripMenuItem}); this.更名PToolStripMenuItem.Name = "更名PToolStripMenuItem"; this.更名PToolStripMenuItem.Size = new System.Drawing.Size(59, 20); this.更名PToolStripMenuItem.Text = "更名(&P)"; // // 更名ToolStripMenuItem // this.更名ToolStripMenuItem.Image = global::FileBatchChangeName.Properties.Resources.圖標(biāo); this.更名ToolStripMenuItem.Name = "更名ToolStripMenuItem"; this.更名ToolStripMenuItem.Size = new System.Drawing.Size(130, 22); this.更名ToolStripMenuItem.Text = "應(yīng)用"; this.更名ToolStripMenuItem.Click += new System.EventHandler(this.更名ToolStripMenuItem_Click); // // 繁體轉(zhuǎn)簡體ToolStripMenuItem // this.繁體轉(zhuǎn)簡體ToolStripMenuItem.Image = global::FileBatchChangeName.Properties.Resources.netspell; this.繁體轉(zhuǎn)簡體ToolStripMenuItem.Name = "繁體轉(zhuǎn)簡體ToolStripMenuItem"; this.繁體轉(zhuǎn)簡體ToolStripMenuItem.Size = new System.Drawing.Size(130, 22); this.繁體轉(zhuǎn)簡體ToolStripMenuItem.Text = "繁體轉(zhuǎn)簡體"; this.繁體轉(zhuǎn)簡體ToolStripMenuItem.Click += new System.EventHandler(this.繁體轉(zhuǎn)簡體ToolStripMenuItem_Click); // // 簡體轉(zhuǎn)繁體ToolStripMenuItem // this.簡體轉(zhuǎn)繁體ToolStripMenuItem.Image = global::FileBatchChangeName.Properties.Resources.netspell; this.簡體轉(zhuǎn)繁體ToolStripMenuItem.Name = "簡體轉(zhuǎn)繁體ToolStripMenuItem"; this.簡體轉(zhuǎn)繁體ToolStripMenuItem.Size = new System.Drawing.Size(130, 22); this.簡體轉(zhuǎn)繁體ToolStripMenuItem.Text = "簡體轉(zhuǎn)繁體"; this.簡體轉(zhuǎn)繁體ToolStripMenuItem.Click += new System.EventHandler(this.簡體轉(zhuǎn)繁體ToolStripMenuItem_Click); // // 幫助HToolStripMenuItem // this.幫助HToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.關(guān)于ToolStripMenuItem}); this.幫助HToolStripMenuItem.Name = "幫助HToolStripMenuItem"; this.幫助HToolStripMenuItem.Size = new System.Drawing.Size(59, 20); this.幫助HToolStripMenuItem.Text = "幫助(&H)"; // // 關(guān)于ToolStripMenuItem // this.關(guān)于ToolStripMenuItem.Image = global::FileBatchChangeName.Properties.Resources.圖標(biāo)__179_; this.關(guān)于ToolStripMenuItem.Name = "關(guān)于ToolStripMenuItem"; this.關(guān)于ToolStripMenuItem.Size = new System.Drawing.Size(94, 22); this.關(guān)于ToolStripMenuItem.Text = "關(guān)于"; this.關(guān)于ToolStripMenuItem.Click += new System.EventHandler(this.關(guān)于ToolStripMenuItem_Click); // // statusStrip1 // this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabel1, this.toolStripStatusLabel2, this.tsslSum, this.toolStripStatusLabel3, this.toolStripProgressBar1, this.tsslError}); this.statusStrip1.Location = new System.Drawing.Point(0, 412); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Size = new System.Drawing.Size(597, 22); this.statusStrip1.TabIndex = 2; this.statusStrip1.Text = "statusStrip1"; // // toolStripStatusLabel1 // this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; this.toolStripStatusLabel1.Size = new System.Drawing.Size(0, 17); // // toolStripStatusLabel2 // this.toolStripStatusLabel2.Name = "toolStripStatusLabel2"; this.toolStripStatusLabel2.Size = new System.Drawing.Size(59, 17); this.toolStripStatusLabel2.Text = "文件總數(shù):"; // // tsslSum // this.tsslSum.AutoSize = false; this.tsslSum.Name = "tsslSum"; this.tsslSum.Size = new System.Drawing.Size(150, 17); this.tsslSum.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // toolStripStatusLabel3 // this.toolStripStatusLabel3.ForeColor = System.Drawing.Color.Gray; this.toolStripStatusLabel3.Name = "toolStripStatusLabel3"; this.toolStripStatusLabel3.Size = new System.Drawing.Size(11, 17); this.toolStripStatusLabel3.Text = "|"; // // toolStripProgressBar1 // this.toolStripProgressBar1.Maximum = 10000; this.toolStripProgressBar1.Name = "toolStripProgressBar1"; this.toolStripProgressBar1.Size = new System.Drawing.Size(200, 16); // // tsslError // this.tsslError.Name = "tsslError"; this.tsslError.Size = new System.Drawing.Size(0, 17); // // splitContainer1 // this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer1.Location = new System.Drawing.Point(0, 24); this.splitContainer1.Name = "splitContainer1"; this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; // // splitContainer1.Panel1 // this.splitContainer1.Panel1.Controls.Add(this.tabControl1); // // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.listView1); this.splitContainer1.Size = new System.Drawing.Size(597, 388); this.splitContainer1.SplitterDistance = 122; this.splitContainer1.SplitterWidth = 1; this.splitContainer1.TabIndex = 1; // // tabControl1 // this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl1.Location = new System.Drawing.Point(0, 0); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; this.tabControl1.Size = new System.Drawing.Size(597, 122); this.tabControl1.TabIndex = 0; // // tabPage1 // this.tabPage1.Controls.Add(this.pictureBox1); this.tabPage1.Controls.Add(this.groupBox2); this.tabPage1.Controls.Add(this.groupBox1); this.tabPage1.Location = new System.Drawing.Point(4, 21); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); this.tabPage1.Size = new System.Drawing.Size(589, 97); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "基本設(shè)置"; this.tabPage1.UseVisualStyleBackColor = true; // // pictureBox1 // this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.pictureBox1.Image = global::FileBatchChangeName.Properties.Resources.gg; this.pictureBox1.Location = new System.Drawing.Point(401, 12); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(182, 79); this.pictureBox1.TabIndex = 5; this.pictureBox1.TabStop = false; // // groupBox2 // this.groupBox2.Controls.Add(this.radioButton5); this.groupBox2.Controls.Add(this.radioButton4); this.groupBox2.Location = new System.Drawing.Point(8, 51); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(387, 40); this.groupBox2.TabIndex = 1; this.groupBox2.TabStop = false; this.groupBox2.Text = "擴展名"; // // radioButton5 // this.radioButton5.AutoSize = true; this.radioButton5.Location = new System.Drawing.Point(124, 18); this.radioButton5.Name = "radioButton5"; this.radioButton5.Size = new System.Drawing.Size(83, 16); this.radioButton5.TabIndex = 4; this.radioButton5.TabStop = true; this.radioButton5.Text = "擴展名小寫"; this.radioButton5.UseVisualStyleBackColor = true; this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged); // // radioButton4 // this.radioButton4.AutoSize = true; this.radioButton4.Location = new System.Drawing.Point(6, 18); this.radioButton4.Name = "radioButton4"; this.radioButton4.Size = new System.Drawing.Size(83, 16); this.radioButton4.TabIndex = 3; this.radioButton4.TabStop = true; this.radioButton4.Text = "擴展名大寫"; this.radioButton4.UseVisualStyleBackColor = true; this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged); // // groupBox1 // this.groupBox1.Controls.Add(this.radioButton3); this.groupBox1.Controls.Add(this.radioButton2); this.groupBox1.Controls.Add(this.radioButton1); this.groupBox1.Location = new System.Drawing.Point(8, 6); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(387, 40); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "文件名"; // // radioButton3 // this.radioButton3.AutoSize = true; this.radioButton3.Location = new System.Drawing.Point(244, 16); this.radioButton3.Name = "radioButton3"; this.radioButton3.Size = new System.Drawing.Size(107, 16); this.radioButton3.TabIndex = 2; this.radioButton3.TabStop = true; this.radioButton3.Text = "第一個字母大寫"; this.radioButton3.UseVisualStyleBackColor = true; this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged); // // radioButton2 // this.radioButton2.AutoSize = true; this.radioButton2.Location = new System.Drawing.Point(124, 16); this.radioButton2.Name = "radioButton2"; this.radioButton2.Size = new System.Drawing.Size(83, 16); this.radioButton2.TabIndex = 1; this.radioButton2.TabStop = true; this.radioButton2.Text = "文件名小寫"; this.radioButton2.UseVisualStyleBackColor = true; this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged); // // radioButton1 // this.radioButton1.AutoSize = true; this.radioButton1.Location = new System.Drawing.Point(6, 16); this.radioButton1.Name = "radioButton1"; this.radioButton1.Size = new System.Drawing.Size(83, 16); this.radioButton1.TabIndex = 0; this.radioButton1.TabStop = true; this.radioButton1.Text = "文件名大寫"; this.radioButton1.UseVisualStyleBackColor = true; this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); // // tabPage2 // this.tabPage2.Controls.Add(this.txtTemplate); this.tabPage2.Controls.Add(this.label5); this.tabPage2.Controls.Add(this.nuAdd); this.tabPage2.Controls.Add(this.label4); this.tabPage2.Controls.Add(this.nuStart); this.tabPage2.Controls.Add(this.label3); this.tabPage2.Controls.Add(this.comboBox2); this.tabPage2.Controls.Add(this.label2); this.tabPage2.Location = new System.Drawing.Point(4, 21); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); this.tabPage2.Size = new System.Drawing.Size(589, 97); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "序號設(shè)置"; this.tabPage2.UseVisualStyleBackColor = true; // // txtTemplate // this.txtTemplate.Location = new System.Drawing.Point(318, 25); this.txtTemplate.Name = "txtTemplate"; this.txtTemplate.Size = new System.Drawing.Size(190, 21); this.txtTemplate.TabIndex = 7; this.txtTemplate.TextChanged += new System.EventHandler(this.txtTemplate_TextChanged); // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(283, 31); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(29, 12); this.label5.TabIndex = 6; this.label5.Text = "模板"; // // nuAdd // this.nuAdd.Location = new System.Drawing.Point(217, 60); this.nuAdd.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.nuAdd.Name = "nuAdd"; this.nuAdd.Size = new System.Drawing.Size(56, 21); this.nuAdd.TabIndex = 5; this.nuAdd.Value = new decimal(new int[] { 1, 0, 0, 0}); this.nuAdd.ValueChanged += new System.EventHandler(this.nuAdd_ValueChanged); // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(161, 64); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(41, 12); this.label4.TabIndex = 4; this.label4.Text = "增量值"; // // nuStart // this.nuStart.Location = new System.Drawing.Point(80, 60); this.nuStart.Name = "nuStart"; this.nuStart.Size = new System.Drawing.Size(56, 21); this.nuStart.TabIndex = 3; this.nuStart.ValueChanged += new System.EventHandler(this.nuStart_ValueChanged); // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(21, 64); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(53, 12); this.label3.TabIndex = 2; this.label3.Text = "起始數(shù)字"; // // comboBox2 // this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox2.FormattingEnabled = true; this.comboBox2.Items.AddRange(new object[] { "pic_#", "file_#"}); this.comboBox2.Location = new System.Drawing.Point(100, 25); this.comboBox2.Name = "comboBox2"; this.comboBox2.Size = new System.Drawing.Size(173, 20); this.comboBox2.TabIndex = 1; this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged); // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(21, 28); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(77, 12); this.label2.TabIndex = 0; this.label2.Text = "選擇預(yù)設(shè)模板"; // // listView1 // this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader1, this.columnHeader2, this.columnHeader3, this.columnHeader4, this.columnHeader5, this.columnHeader6, this.columnHeader7}); this.listView1.Dock = System.Windows.Forms.DockStyle.Fill; this.listView1.Font = new System.Drawing.Font("宋體", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.listView1.FullRowSelect = true; this.listView1.Location = new System.Drawing.Point(0, 0); this.listView1.MultiSelect = false; this.listView1.Name = "listView1"; this.listView1.Size = new System.Drawing.Size(597, 265); this.listView1.TabIndex = 0; this.listView1.UseCompatibleStateImageBehavior = false; this.listView1.View = System.Windows.Forms.View.Details; // // columnHeader1 // this.columnHeader1.Text = "文件名"; this.columnHeader1.Width = 100; // // columnHeader2 // this.columnHeader2.Text = "預(yù)覽"; this.columnHeader2.Width = 100; // // columnHeader3 // this.columnHeader3.Text = "擴展名"; // // columnHeader4 // this.columnHeader4.Text = "日期"; this.columnHeader4.Width = 90; // // columnHeader5 // this.columnHeader5.Text = "路徑"; this.columnHeader5.Width = 80; // // columnHeader6 // this.columnHeader6.Text = "大小"; this.columnHeader6.Width = 83; // // columnHeader7 // this.columnHeader7.Text = "結(jié)果"; this.columnHeader7.Width = 80; // // notifyIcon1 // this.notifyIcon1.Text = "notifyIcon1"; this.notifyIcon1.Visible = true; // // openFileDialog1 // this.openFileDialog1.Multiselect = true; // // saveFileDialog1 // this.saveFileDialog1.Filter = "文本文檔(*.txt)|*.txt"; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(597, 434); this.Controls.Add(this.splitContainer1); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.menuStrip1); this.DoubleBuffered = true; this.MainMenuStrip = this.menuStrip1; this.MaximizeBox = false; this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "批量更名器"; this.Load += new System.EventHandler(this.Form1_Load); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); this.splitContainer1.ResumeLayout(false); this.tabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.tabPage2.ResumeLayout(false); this.tabPage2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nuAdd)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nuStart)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem 文件ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 添加文件ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 總在最前ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 更名PToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 幫助HToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 導(dǎo)出文件列表ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 退出ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 更名ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 繁體轉(zhuǎn)簡體ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 簡體轉(zhuǎn)繁體ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 關(guān)于ToolStripMenuItem; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.ListView listView1; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.RadioButton radioButton2; private System.Windows.Forms.RadioButton radioButton1; private System.Windows.Forms.RadioButton radioButton3; private System.Windows.Forms.RadioButton radioButton5; private System.Windows.Forms.RadioButton radioButton4; private System.Windows.Forms.ColumnHeader columnHeader1; private System.Windows.Forms.ColumnHeader columnHeader2; private System.Windows.Forms.ColumnHeader columnHeader3; private System.Windows.Forms.ColumnHeader columnHeader4; private System.Windows.Forms.ColumnHeader columnHeader5; private System.Windows.Forms.ColumnHeader columnHeader6; private System.Windows.Forms.ColumnHeader columnHeader7; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.ComboBox comboBox2; private System.Windows.Forms.Label label2; private System.Windows.Forms.NumericUpDown nuAdd; private System.Windows.Forms.Label label4; private System.Windows.Forms.NumericUpDown nuStart; private System.Windows.Forms.Label label3; private System.Windows.Forms.NotifyIcon notifyIcon1; private System.Windows.Forms.TextBox txtTemplate; private System.Windows.Forms.Label label5; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2; private System.Windows.Forms.ToolStripStatusLabel tsslSum; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel3; private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1; private System.Windows.Forms.ToolStripStatusLabel tsslError; private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.SaveFileDialog saveFileDialog1; }
到此這篇關(guān)于C#實現(xiàn)批量更改文件名稱大小寫或擴展名的文章就介紹到這了,更多相關(guān)C#更改文件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
您可能感興趣的文章: