Loading
0

C#文件重命名

若该文章解决了您的问题,可否收藏+评论+分享呢?
C#文件重命名

private void btn_start_Click(object sender, EventArgs e)
        {
            //找到目录
            DirectoryInfo directoryinfo = new DirectoryInfo(txt_path.Text);
            int i = 1;
            //读取当前目录文件信息
            foreach (var item in directoryinfo.GetFiles())
            {
              
                string destPath = Path.Combine(txt_path.Text, i + item.Extension);
                if (item.Name.Length > 10)
                {
                    //判断是否重名
                    if (!File.Exists(destPath))
                    {
                        item.MoveTo(destPath);
                    }
                    i++;
                }
            }
            MessageBox.Show("操作完成");
            //通过长宽新建文件夹
            //将该尺寸的文件移动到文件夹下并重命名


        }

        private void txt_path_Click(object sender, EventArgs e)
        {
            DialogResult dr = folderBrowserDialog1.ShowDialog();
            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                txt_path.Text = folderBrowserDialog1.SelectedPath;
            }
        }

声明:站长码字很辛苦啊,转载时请保留本声明及附带文章链接:https://blog.tag.gg/showinfo-23-36068-0.html
亲爱的:若该文章解决了您的问题,可否收藏+评论+分享呢?
上一篇:C#文件夹排序
下一篇:c#加密解密