I am copying files from one location to another. I encountered an issue where sometimes a file with the same name would try to save and it would break the program. So I added the logic below to add a number to the filename before copying it:

```
                int counter = 0;
                try
                {
                    File.Copy(FileToCopy, FileToSave);

                }
                catch (Exception)
                {
                    string CurrentFileName = FileToSave.Split('\\', '\\')[4];
                    string CurretFilePrefix = CurrentFileName.Split('.')[0];
                    string CurrentFileSuffix = CurrentFileName.Split('.')[1];
                    string UpdatedFileName = CurretFilePrefix + "_" + counter + "." + CurrentFileSuffix;
                    File.Copy(FileToCopy, UpdatedFileName);
                    counter++;
                }

```

However, this is now causing a crash saying the file already exists:

[![enter image description here](https://i.stack.imgur.com/s5utP.png)](https://i.stack.imgur.com/s5utP.png)

When I check the file does not exist:

[![enter image description here](https://i.stack.imgur.com/7y3f6.png)](https://i.stack.imgur.com/7y3f6.png)

Why am I getting this exception? How do I save copies of these files?