0

I'm trying to go through and rename a bunch of my JPG but what I'm trying won't work and i have no idea what else to try.

The program works for folders and .txt but not my .JPG images, there are other solutions to renaming but not for .JPG. Does anyone know what I can change?

I have also tried File.Move but they both return the same error message, File not found exception was unhandled. Could not find file (I am certain my path is correct)

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");
    }
}
Verv
  • 2,385
  • 2
  • 23
  • 37

1 Answers1

2

Use System.IO.File.Move, not Directory Check Rename a file in C#

Community
  • 1
  • 1
jezzarax
  • 417
  • 2
  • 10