Export (0) Print
Expand All

VSProject2.WebReferencesFolder Property 

Gets the ProjectItem object representing the Web References folder of the project. If the folder does not exist, this property returns Nothing (a a null reference (Nothing in Visual Basic) reference).

Namespace: VSLangProj80
Assembly: VSLangProj80 (in vslangproj80.dll)

ProjectItem WebReferencesFolder { get; }
/** @property */
ProjectItem get_WebReferencesFolder ()

function get WebReferencesFolder () : ProjectItem

Property Value

A ProjectItem object representing the Web References folder.

A project's Web references may be retrieved by accessing the ProjectItems property of the WebReferencesFolder.

A project contains at most one Web References folder. The folder may be created by using the CreateWebReferencesFolder method. In addition, the folder is created automatically when the first Web reference is added to the project by using the CreateWebReferencesFolder method.

In a Visual Basic, Visual C#, and Visual J# project, the Kind property of the WebReferencesFolder project item is always vsProjectItemKindPhysicalFolder because Visual Basic, Visual C#, and Visual J# projects support only physical files.

This example creates a Web references folder, if one does not already exist, and displays some of the folder properties in a message box. To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples. Open a Visual Basic Visual C#, or Visual J# project before running this example.

using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;

public void OnConnection(object application, ext_ConnectMode
 connectMode, object addInInst, ref Array custom)
{
    applicationObject = (DTE2)application;
    addInInstance = (AddIn)addInInst;
    WebReferencesFolderExample((DTE2)applicationObject);
}

public void WebReferencesFolderExample( DTE2 dte ) 
{ 
    // This example assumes that the first project in the 
    // solution is a Visual Basic C# or J# project.
    VSProject2 aVSProject = ( ( VSProject2 )
(applicationObject.Solution.Projects.Item( 1 ).Object ) ); 
    // Add a new folder if it does not already exist.
    if ( ( aVSProject.WebReferencesFolder == null ) ) 
    { 
        ProjectItem newFolder = null; 
        newFolder = aVSProject.CreateWebReferencesFolder(); 
    } 
    // Display the name of the Web references folder.
    ProjectItem theFolder = aVSProject.WebReferencesFolder; 
    MessageBox.Show( "The name of the WebReferences folder is " 
+ theFolder.Name + "."); 
    // All Visual Basic, J#, and C# Web references folders are physical.
    if ( ( theFolder.Kind == 
EnvDTE.Constants.vsProjectItemKindPhysicalFolder ) ) 
    { 
        MessageBox.Show( theFolder.Name + " is a physical folder."); 
    } 
    MessageBox.Show( "There are " +
 theFolder.ProjectItems.Count.ToString() + " Web references."); 
}
Show:
© 2014 Microsoft