IVSSItem.Version Property
Gets a reference of the IVSSItem type to an object that represents a particular IVSSVersion of a file or a project in the IVSSVersions collection.
Namespace: Microsoft.VisualStudio.SourceSafe.Interop
Assembly: Microsoft.VisualStudio.SourceSafe.Interop (in microsoft.visualstudio.sourcesafe.interop.dll)
Syntax
'Declaration
ReadOnly Property Version ( _
<InAttribute> <OptionalAttribute> Version As Object _
) As VSSItem
'Usage
Dim instance As IVSSItem
Dim Version As Object
Dim value As VSSItem
value = instance.Version(Version)
VSSItem Version [
[OptionalAttribute] [InAttribute] Object Version
] { get; }
property VSSItem^ Version [Object^] {
VSSItem^ get ([InAttribute] [OptionalAttribute] Object^ Version);
}
/** @property */
VSSItem get_Version (/** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ Object Version)
JScript supports the use of indexed properties, but not the declaration of new ones.
Parameters
Property Value
A reference of the IVSSItem type to an object that represents a particular IVSSVersion of a file or a project in the IVSSVersions collection.
Remarks
[IDL]
HRESULT Version ([in,optional]VARIANT Version, [out,retval]IVSSItem **ppIItem);
The IVSSVersions collection is one-based.
Parameter Version may be represented in one of the following formats:
Valid date string |
A version of a file or a project on that particular date |
"12/15/03" |
Valid numerical string |
A numbered version of a file or a project |
"7" |
Label |
A version that has neither a date or a number associated with it |
"Rel1" |
Example
The following example demonstrates how to use the Version property to retrieve a specific version of the file using a numeric index. 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