locked
How to add a virtual folder by using JScript RRS feed

  • Question

  •         I want to implement  add a virtual folder on a existing vc project. My code as follows:

    var item = null;
    var folderName = "MyFolder";
    
    try {
       // attempt to retrieve the existing folder as a project item
       item = vcProject.ProjectItems.Item(folderName);
    } catch (e) {
       // something prevented us from getting the folder
       item = null;
    }
    
    if (item == null) {
       item = vcProject.ProjectItems.AddFolder(folderName);
    }
           a error occurred, the errpr tip is : Object doesn't support this action. it means vcProject.ProjectItems doesn't support AddFolder this method.

    My environment: VisualStudio 2013, Win 7 + sp1 64 bit


    前无古人,后无来者

    Tuesday, March 27, 2018 6:25 AM

All replies

  • Hi clever101,

    Please try the following code, which using Microsoft.Build.Evaluation.Project to add folder into project.

    var pro = new Microsoft.Build.Evaluation.Project("ProjectPath");
    pro.AddItem("Folder", "Folder Path");
    pro.Save();
    
    

    Best regards,

    Zhanglong


    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.

    Friday, March 30, 2018 8:25 AM