locked
A file or folder with the name 'xxxxx' already exists. Please give a unique name to the item you are adding, or delete the exisiting item first.

    Question


  • Im getting this error,everytime i try to add new file to solution in c#:
    ----
    A file or folder with the name 'xxxxx' already exists. Please give a unique name to the item you are adding, or delete the exisiting item first.



    How can i fix it??? I dont have files with that name is solution.

    Thanks for your help
    Wednesday, June 11, 2008 8:41 PM

Answers

  • SP1 of VS?  What version of VS do you have?  If you are running VS2008 SP1 beta then it could be a beta problem.  If you're running VS2005 SP1 then it is something else.

    I've got some projects that lay out like that and I don't have the same problem you do so I don't believe it to be a blatant bug in VS but there could be some boundary scenario that we're overlooking.  Still, if you shut down VS and restart it then it has to be something to do with the solution/project you're working with.

    I guess scanning the SLN/proj file for folders that are missing didn't turn up anything?

    Michael Taylor - 6/13/08
    http://p3net.mvps.org
    • Marked as answer by jack 321 Monday, June 16, 2008 3:56 AM
    Friday, June 13, 2008 7:43 PM
    Moderator

All replies

  • VS (for most languages at least) defaults to requiring that a solution is laid out on disk in the same manner it is in the solution.  So if you create FolderA in your solution then it'll create FolderA on disk.  Where problems start to arise is if FolderA already exists on disk.  In this case VS will complain because it can't create FolderA because it already exists on disk (but not in the solution).

    If the folder/file already exists on disk then you can add it to the solution by selecting the Show All Files button at the top of Solution Explorer.  You can then see the folders/files that are not in the solution but present on disk.  You can right-click these items and select Include in Project to add them to the project.  For folders it'll automatically add each children as well.

    Michael Taylor - 6/12/08
    http://p3net.mvps.org
    Thursday, June 12, 2008 12:59 PM
    Moderator
  • The problem is,that solution dont have this folder or file,no matter how i call file. It seems to me something wrong with IDE itself for not allowing to add any files or folders.
    Thursday, June 12, 2008 2:16 PM
  • Create a new solution and project.  Add a new folder.  Does it work?  How about a new file?

    Michael Taylor - 6/12/08
    http://p3net.mvps.org
    Thursday, June 12, 2008 2:18 PM
    Moderator
  • New solution works fine,but problematic solution use source control Perforce,on other computers that solution works fine.
    Friday, June 13, 2008 4:35 PM
  • Just to confirm, you have verified that the folder you are trying to create in the solution does not already exist in the file system (using Explorer)?  If it doesn't exist then it could be something with the SCC plugin (Perforce) although it shouldn't get involved at this point.

    You could try temporarily disabling the SCC binding in the solution and see if you can create the folder.  If you can then it is an issue with the SCC provider otherwise it isn't Perforce.

    Michael Taylor - 6/13/08
    http://p3net.mvps.org
    Friday, June 13, 2008 4:39 PM
    Moderator
  • I unbind solution from source safe, and still experienced same problem.
    Where this message come from? Sln file?
    Friday, June 13, 2008 5:21 PM
  • The message comes from the IDE when it determines that the folder/file you're creating already exists in the solution or it already exists on disk.  In either of these cases it'll fail the call.  The only time SCC gets into the picture is when it needs to check out the solution/project so that you can modify it.  If you unbound the solution/project then the SCC isn't the issue.

    Have you tried copying the entire solution to another machine and trying it again?  This is a slightly different scenario than just trying to open the solution on another machine via Perforce.  Are you using SourceSafe or Perforce?  You mentioned both.

    Michael Taylor - 6/13/08
    http://p3net.mvps.org
    Friday, June 13, 2008 5:25 PM
    Moderator
  • Im sorry for confusing you by source safe i mean source control.
    Im using Perforce. Let me try to copy to another machine unbinded solution. I will let you know in few.
    Friday, June 13, 2008 5:28 PM
  • It works on other computer.
    Any other suggestions?
    Friday, June 13, 2008 6:01 PM
  •  I'm at a complete lose as to why it wouldn't let you create the solution.  At this point I'm going to start recommending the standard stuff to check as it does appear to be a problem with either your specific user account or the directory where the solution resides.

    1. Verify you have sufficient drive space.
    2. Use Process Monitor to monitor VS when you try to create the folder.  Look for any security issues that might arise.
    3. Open the SLN file (and the proj file if it applies to a project) and scan through looking for any folders/files that might not appear on disk.

    One more thing you can try, as sort of a workaround:

    1. Create the new folder in Windows Explorer
    2. Go to VS and open Solution Explorer
    3. Select Show All Files from top of SE window
    4. Select the newly created folder and right-click
    5. Select Include in Project

    This should add the folder to the solution.

    Michael Taylor - 6/13/08
    http://p3net.mvps.org

    Friday, June 13, 2008 6:08 PM
    Moderator
  • Ok Michael,
    I narrow down problem,
    My solution have 3 projects
    Class Library
    Web Project
    Test Project (Created by going to Test on IDE menu)


    If i remove Test project,everything working fine.I can add/remove file/folders.

    Problem is Test in IDE, when i click on  antyhing like New Test... or try clicking on any menu under Windows,nothing happened.
    I think this portion of IDE doesnt work,and thats why it create all this problems.
    Now i need to investigate why Test not working at all in SP1.

    Any suggestions?


    Friday, June 13, 2008 7:02 PM
  • SP1 of VS?  What version of VS do you have?  If you are running VS2008 SP1 beta then it could be a beta problem.  If you're running VS2005 SP1 then it is something else.

    I've got some projects that lay out like that and I don't have the same problem you do so I don't believe it to be a blatant bug in VS but there could be some boundary scenario that we're overlooking.  Still, if you shut down VS and restart it then it has to be something to do with the solution/project you're working with.

    I guess scanning the SLN/proj file for folders that are missing didn't turn up anything?

    Michael Taylor - 6/13/08
    http://p3net.mvps.org
    • Marked as answer by jack 321 Monday, June 16, 2008 3:56 AM
    Friday, June 13, 2008 7:43 PM
    Moderator
  • Its VS2008 SP1 Beta, Windows XP environment.

    No,solution is good,if i remove reference for unit test proj then it works.
    I guess now i will try to fix Test option in VS.

    Thanks for your help!
    Friday, June 13, 2008 9:38 PM
  • Co-incidentally I encountered the same problem in VS 2008 last night. When I retry the operation today it works ok. Leading up to the problem I had been refactoring some other solutions and creating the same folder. Maybe there was some confusion over the working directory vs. the solution’s actual folder?

    LPD.

    Tuesday, June 17, 2008 6:22 AM
  • Wow....I get the same thing, and mine also starts working when I remove the Test project!

    I'm trying to use ASP.NET MVC. I remember Scott Hanselman saying you could choose not to use Test Projects by clicking the "I Suck Button", but this is a whole different ball game.

    Any ideas why this is happening?

    Josh
    Friday, July 04, 2008 11:28 PM
  • We can assume then that there is a bug when you have a test project in your solution.  I'm running RTM of VS2008 and I don't have any problems creating folders with test projects.  The OP is using SP1 beta so I'd lean toward it being a SP1 beta issue.  If others are not using the beta then it could be related to an addin that is being used.  More information would be useful here.

    Jojo, please submit the issue to the Connect site (http://connect.microsoft.com) or the appropriate beta testing forums for VS2008.  Please post the link when you're done so that the other folks can add their comments and track the issue as well.  Thanks.

    Michael Taylor - 7/7/08
    http://p3net.mvps.org
    Monday, July 07, 2008 1:34 PM
    Moderator
  • I had the same problem with Test Projects on VS2008 SP1 + ASP.NET MVC Preview4.

    Try running "devenv /setup" in VS command prompt.

    Art
    • Proposed as answer by Chris Moretton Tuesday, March 09, 2010 10:03 AM
    Saturday, August 23, 2008 4:53 PM
  • Had the same problem,

    another solution which worked for me which wasn't too much of a hassle, just unload your test projects from the solution explorer, and reload them as soon as you've created your new files/folders. Much easier than removing them completely and re-adding them again later when you want to use them.

    regards,
    Chris
    Tuesday, March 09, 2010 10:06 AM
  • Looks like still the issue is not resolved in VS TFS development Edition 2008.I had the same issue and it worked when i removed my test projects.

    Thanks for the suggestions.

    Monday, May 10, 2010 3:51 PM