locked
Add Folder to Project RRS feed

  • Question

  • How would you go about adding a Folder to a Project in a Solution. I do know that `IVsProject::AddItem` exists, however I am not sure how this would allow me to add a new Folder? Additionally I would really want to avoid the DTE, if somehow possible.
    Saturday, March 21, 2020 2:39 AM

All replies

  • Hi 24_minutes,

    Sorry for delay in reply.

    As my research, there are not related apis which can add folder or directory into a project except the dte interface.

    So to meet your requirement without dte, you can create a new folder in your project directory, then add it modifying proj file. Note: the proj file is an xml document.

    Please refer here: Directory.CreateDirectory Method and how to programmatically add XmlNode to an XmlNodeList 

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Monday, March 23, 2020 8:40 AM
  • That is sad that this is the only option, thank you anyway!
    Tuesday, March 31, 2020 12:46 AM
  • Hi 24_minutes,

    Sorry for this inconvenience. If you have other questions about VS integrate, please feel free to contact us.

    Have a nice day.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, March 31, 2020 1:49 AM
  • So I tried to change the content of the .csproj as you suggested which works perfectly fine, however I am getting the following message:

    Is there any way I can suppress this message and/or reload the project/update the hierarchy manually?

    I figured that Saving all files before changing the document works, however the Hierarchy doesn't update.



    • Edited by 24_minutes Tuesday, March 31, 2020 6:12 PM
    Tuesday, March 31, 2020 6:07 PM
  • Hi 24_minutes,

    Thank you for feedback.

    May you can use IVsSolution4 class to unload this project then reload it. And you could refer this sample about using it.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Wednesday, April 1, 2020 9:50 AM