Reputation: 870
I try to add a new file to my source controlled solution and receive this message:
A file or folder with the name 'xxx' already exists. Please give a unique name to the item you are adding, or delete the existing item first.
I'm 100% sure that there is no file with the given name.
So how do I get VS to add items again?
Upvotes: 71
Views: 81103
Reputation: 746
I just had a tab open with the file name, closing it solved the issue for me
Upvotes: 0
Reputation: 2990
I right clicked and removed folder. Then Clicked upper the folder I wanted to create project in and created project. In the Location section I opened the File explorer and the file I had deleted still appeared -> deleted it from here and then went ahead.
Upvotes: 3
Reputation: 31686
Steps if a folder is Missing
Solution Explorer
window
Include in Project
to add into the project in the project view.Upvotes: 19
Reputation: 350
In my case, when trying to add a new project to a solution, even though a project with the same name had been removed from the solution in visual studio (2019), I had to open file explorer and delete the folder for the removed project.
Upvotes: 0
Reputation: 276
Click on Show All Files Menu in Solution Explorer and See That file in Controller, Views and Model Folder and delete that from there also
Upvotes: -2
Reputation: 304
If you're using MVC, and trying to create a new Controller, you should also check the Views and Models. Even though there was no folder or file with the Controller name, I had to delete a View folder with the same name (that already existed for some reason) using Show All Files
and rebuild the solution.
Upvotes: 10
Reputation: 1283
Visual Studio 2017 v 15.9.12 ... I ran into this problem, but with no actual folder conflict. In my case, I had solution folder named NewOrder, and I was trying to create a child project with the same name, but encountered the above error. I tried closing and reopening the solution (didn't restart VS so not sure if that would have made a difference) but here's what worked for me.
Now everything works fine. I restarted VS again just for good measure and all works fine now.
Upvotes: 0
Reputation: 55
The project file was unloaded in visual studio 2017
The easiest way is to copy your project folder and paste different repository then open your project in visual studio then after run the project, it should work. for example (D:--------->E:[here i mentioned repository these things])
Upvotes: 0
Reputation: 33
You need to give attention if adding a file automatically add other files/folders..for example if I added a controller which automatically add folder with controller name in views..I couldn't add controller .cs
file until I deleted folder with controller name from views.
Upvotes: -4
Reputation: 141
Simply, On Solution Explorer Right CLick on Project's name -> Unload Project. then right click on the same project and click 'Reload'.
Problem is Fixed (y)
Upvotes: 13
Reputation: 1880
Restarting Visual Studio didn't help, the folder is cached on the system.
Open Solution Explorer
there is an icon that looks like a many Pages: which is the
Show All Files
. Once clicked, one is able to see the hidden, to the visual studio project, the folder that was causing this error. (Look for the folder in the View section.)
After I deleted the unwanted folder, and Rebuild Project, You should be able to Create the controller which will create the view automatically...
Upvotes: 117