Share via


IVSSItem.Type Property 

Gets a value indicating whether a particular item is a file or a project.

Namespace: Microsoft.VisualStudio.SourceSafe.Interop
Assembly: Microsoft.VisualStudio.SourceSafe.Interop (in microsoft.visualstudio.sourcesafe.interop.dll)

Syntax

'Declaration
ReadOnly Property Type As Integer
'Usage
Dim instance As IVSSItem
Dim value As Integer

value = instance.Type
int Type { get; }
property int Type {
    int get ();
}
/** @property */
int get_Type ()
function get Type () : int

Property Value

A value indicating whether a particular item is a file or a project.

Item

Constant

Value

Project

VSSITEM_PROJECT

0

File

VSSITEM_FILE

1

Remarks

[IDL]

HRESULT Type ([out,retval]int *piType);

Example

The following example demonstrates how to use the Type property to determine whether an item is a file or a project. To run this example:

  • Create a $/TestFolder/ project.

    $/TestFolder/ contains: test.txt.

[C#]

using System;
using Microsoft.VisualStudio.SourceSafe.Interop;

public class IVSSTest
{
    public static void Main()
    {
        string testFolder = "$/TestFolder";
        string testFile = "$/TestFolder/test.txt";

        // Create a VSSDatabase object.
        IVSSDatabase vssDatabase = new VSSDatabase();

        // Open a VSS database using network name 
        // for automatic user login.
        vssDatabase.Open(@"C:\VSSTestDB\srcsafe.ini", 
                         Environment.UserName, ""); 

        // Get IVSSItem references to the project and the file objects.
        IVSSItem vssFolder = vssDatabase.get_VSSItem(testFolder, false);
        DisplayType(vssFolder);
        VSSItem vssFile = vssDatabase.get_VSSItem(testFile, false);
        DisplayType(vssFile);
    }

    private static void DisplayType(IVSSItem vssItem)
    {
        switch((VSSItemType)vssItem.Type)
        {
            case VSSItemType.VSSITEM_FILE:
                Console.WriteLine(vssItem.Spec + " is a file");
                break;
            case VSSItemType.VSSITEM_PROJECT:
                Console.WriteLine(vssItem.Spec + " is a project");
                break;
            default:    
                Console.WriteLine("Is unknown type");
                break;
        }
    }
}

Output:

$/TestFolder is a project

$/TestFolder/test.txt is a file

See Also

Reference

IVSSItem Interface
IVSSItem Members
Microsoft.VisualStudio.SourceSafe.Interop Namespace