c#更改JPEG图像的名称

本文关键字:图像 更改 JPEG | 更新日期: 2023-09-27 18:10:03

我正在尝试重新命名一堆我的JPG,但我所尝试的不会工作,我不知道还可以尝试什么。

该程序适用于文件夹和。txt,但不是我的。jpg图像,还有其他的解决方案来重命名,但不适用。jpg。有人知道我能改变什么吗?

我也尝试过File.Move,但它们都返回相同的错误信息,File not found exception was unhandled. Could not find file(我确信我的路径是正确的)

private void startRenaming_Click(object sender, EventArgs e)
{
    string old_name = @"C:'Users'u587945'Desktop'Vial_Suction_Test'Postion_1'Cycle_1.JPG",
           new_name = @"C:'Users'u587945'Desktop'Vial_Suction_Test'Postion_1'Cycle_1_Vial_1.JPG";
    bool exists = System.IO.Directory.Exists(old_name);
    if (exists)
    {
        MessageBox.Show("Found Directory!!!");
        System.IO.Directory.Move(old_name, new_name);
    }
    else
    {
        MessageBox.Show("Directory not found");
    }
}

c#更改JPEG图像的名称

使用System.IO.File。移动,而不是目录勾选"在c#中重命名文件"