Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to add files, get error message: The operation couldn't be completed. File exists

I need to replace some images in my application. As a result I deleted them from Xcode and now when I try to add them again I get this error: enter image description here

and I am sure that that file does not exist in the project because I just deleted it. Also when I try to look for that file it does not exist.

like image 384
Tono Nam Avatar asked Sep 01 '11 19:09

Tono Nam


People also ask

How do you force delete a file even if it is open?

To do this, start by opening the Start menu (Windows key), typing run , and hitting Enter. In the dialogue that appears, type cmd and hit Enter again. With the command prompt open, enter del /f filename , where filename is the name of the file or files (you can specify multiple files using commas) you want to delete.

How do I force delete a folder that is open in another program?

If the file you want to delete is in an “exe” file of a program, try closing the program first, then attempt to delete the file again. You can also try restarting your PC to close down any running programs or closing the apps that might be using the program you want to delete.

Can't delete file because it is open in system?

To do this, start by opening the Start menu (Windows key), typing run, and hitting Enter. In the dialogue that appears, type cmd and hit Enter again. With the command prompt open, enter del /f filename, where filename is the name of the file or files (you can specify multiple files using commas) you want to delete.


3 Answers

Try this:

  1. go to the folder were the old image was and place it there again.
  2. go to xcode and click on add files to xcode, select the old image again and add it.
  3. remove the image form xcode both its reference and physically.
  4. add the new image (you can drag and drop to xcode or use add files to xcode)

Hope this helps

like image 185
Lio Avatar answered Oct 14 '22 17:10

Lio


It's related to an Xcode bug I filed a while ago:

15-Mar-2011 06:26 PM Johannes Fahrenkrug: Summary: When I try to copy a bunch of files via drag and drop to my Xcode project, check the "copy to project" checkbox and one of the files that I want to copy already exists, Xcode stops with an error. So far, so good. But when I try to copy again (without the file that already existed), I get an "Multiple errors occurred while copying the files" message. It turns out, that Xcode had copied some of the files and had left them on the disk but had not added them to the project. So I have to manually delete them from disk and the drag and drop them again.

Steps to Reproduce: Copy 3 files to your project via drag and drop. One of the files has to have a filename that already exsits. Wait for the error, then just copy the 2 files that don't exist in the project yet.

Expected Results: It should copy the files.

Actual Results: I craps out with an error.

Regression:

Notes: The file names might be important too: If the already exsiting file starts with an "a" and the others with a "z", it might be OK because it craps out on the first file and doesn't copy anything.

like image 42
Johannes Fahrenkrug Avatar answered Oct 14 '22 18:10

Johannes Fahrenkrug


the files that were copied prior to the first error are there, they just have not been added to the target. You need to make them members of the target. It was the same behaviour in xCode 3.x. So after you do that, just drag the remaining files into the project.

like image 38
YvesLeBorg Avatar answered Oct 14 '22 16:10

YvesLeBorg