IVSSItem.Versions Property
Gets a reference of the IVSSVersions type to an object that represents a collection of all versions 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 Versions ( _
<InAttribute> <OptionalAttribute> Optional iFlags As Integer = 0 _
) As IVSSVersions
'Usage
Dim instance As IVSSItem
Dim iFlags As Integer
Dim value As IVSSVersions
value = instance.Versions(iFlags)
IVSSVersions Versions [
[OptionalAttribute] [InAttribute] int iFlags
] { get; }
property IVSSVersions^ Versions [int] {
IVSSVersions^ get ([InAttribute] [OptionalAttribute] int iFlags);
}
/** @property */
IVSSVersions get_Versions (/** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ int iFlags)
JScript supports the use of indexed properties, but not the declaration of new ones.
Parameters
Property Value
A reference of the IVSSVersions type to an object that represents a collection of all versions of a file or a project.
Remarks
[IDL]
HRESULT Versions ([in, defaultvalue(0)]long iFlags, [out,retval]IVSSVersions **ppIVersions);
Valid flags include: VSSFLAG_RECURSNO, VSSFLAG_RECURSYES, VSSFLAG_HISTIGNOREFILES.
Example
The following example demonstrates how to use the Versions property to retrieve all versions of the file by iterating through a IVSSVersions collection. 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
[Visual Basic]
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