Share via


IVSSItem.VersionNumber Property 

Gets a IVSSVersion number of 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 VersionNumber As Integer
'Usage
Dim instance As IVSSItem
Dim value As Integer

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

Property Value

A IVSSVersion number of a file or a project.

Remarks

[IDL]

HRESULT VersionNumber ([out,retval]long *piVersion);

The IVSSVersion number indicates how many revisions a file or a project has undergone since it was added to SourceSafe.

Example

The following example demonstrates how to use the VersionNumber property to retrieve version numbers of the file. To run this example:

  • Create a $/TestFolder/ project.

    $/TestFolder contains test.txt file which has four versions.

[C#]

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

public class IVSSTest
{
    public static void Main()
    {
        // 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 an IVSSItem reference to the file object.
        IVSSItem vssFile = 
                 vssDatabase.get_VSSItem("$/TestFolder/test.txt", false);

        // Use default (0) setting for get_Versions(0)
        Console.Write("{0} has following versions:", vssFile.Spec);
        foreach(IVSSVersion vssVersion in vssFile.get_Versions(0))
            Console.Write(" {0}", vssVersion.VersionNumber);
 
        // Each version can be accessed through 1-based index.
        IVSSItem vssFileVersion = vssFile.get_Version(2);
        Console.WriteLine("\nIndex 2 retrieves version {0}", 
                          vssFileVersion.VersionNumber);
    }
}

Output:

$/TestFolder/test.txt has following versions: 4 3 2 1

Index 2 retrieves version 2

Imports System
Imports Microsoft.VisualStudio.SourceSafe.Interop

Module IVSSTest

    Public Sub Main()

        ' Create a VSSDatabase object.
        Dim vssDatabase As New VSSDatabase

        ' Open a VSS database using automatic login for security.
        vssDatabase.Open("C:\VSSTestDB\srcsafe.ini", Environment.UserName, "")

        ' Create IVSSItem references to the test files.
        Dim vssFile As IVSSItem = _
                       vssDatabase.VSSItem("$/TestFolder/test.txt", False)

        ' Default (0) settings should be used unless there is some _
        ' particular reason to override them.
        Console.Write("{0} has following versions:", vssFile.Spec)
        For Each vssVersion As IVSSVersion In vssFile.Versions(0)
            Console.Write(" {0}", vssVersion.VersionNumber)
        Next vssVersion

        ' Each version can be accessed through 1-based index.
        Dim vssFileVersion As IVSSItem = vssFile.Version(2)
        Console.WriteLine(vbLf + "Index 2 retrieves version {0}", _
                          vssFileVersion.VersionNumber)

    End Sub 'Main

End Module

Output:

$/TestFolder/test.txt has following versions: 4 3 2 1

Index 2 retrieves version 2

See Also

Reference

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