IVSSItem.Checkouts Property
Gets a reference of the IVSSCheckouts type to an object that represents a IVSSCheckouts collection of a file.
Namespace: Microsoft.VisualStudio.SourceSafe.Interop
Assembly: Microsoft.VisualStudio.SourceSafe.Interop (in microsoft.visualstudio.sourcesafe.interop.dll)
Syntax
'Declaration
ReadOnly Property Checkouts As IVSSCheckouts
'Usage
Dim instance As IVSSItem
Dim value As IVSSCheckouts
value = instance.Checkouts
IVSSCheckouts Checkouts { get; }
property IVSSCheckouts^ Checkouts {
IVSSCheckouts^ get ();
}
/** @property */
IVSSCheckouts get_Checkouts ()
function get Checkouts () : IVSSCheckouts
Property Value
A reference of the IVSSCheckouts type to an object that represents a IVSSCheckouts collection of a file.
Remarks
[IDL]
HRESULT Checkouts ([out,retval]IVSSCheckouts **ppICheckouts);
If the file is not checked out, the Checkouts collection has no elements. If the file is checked out once, there is a single element in the collection. One file may have multiple checkouts by different users or by the same user to multiple machines.
When you iterate through the Checkouts collection, you move chronologically from the most recent checkout to the earliest one. You can verify whether a particular checkout is the one you want by validating one or more of its properties (Comment, Date, LocalSpec, Machine, Project, UserName, and VersionNumber).
The Checkouts property applies to file objects only, if you attempt to access the Checkouts property of a project object, a run-time error is generated.
Example
The following example demonstrates how to use the Checkouts property by iterating through Checkouts collection.
To perform this test, the file $/A/a.txt must be checked out by two users. Multiple checkouts must be enabled by the VSS Administrator. To enable multiple checkouts, on the Tools menu, click Options, click the General tab, select the Allow Multiple Checkouts check box, and click OK.
[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("$/A/a.txt", false);
foreach(IVSSCheckout vssCheckout in vssFile.Checkouts)
{
Console.WriteLine("Checked out to : {0}", vssCheckout.Username);
Console.WriteLine("Comment : {0}", vssCheckout.Comment);
Console.WriteLine("Date : {0}", vssCheckout.Date);
Console.WriteLine("LocalSpec : {0}", vssCheckout.LocalSpec);
Console.WriteLine("Machine : {0}", vssCheckout.Machine);
Console.WriteLine("Project : {0}", vssCheckout.Project);
Console.WriteLine("VersionNumber : {0}", vssCheckout.VersionNumber);
Console.WriteLine();
}
Console.WriteLine("Number of Checkouts: " + vssFile.Checkouts.Count);
Console.WriteLine("\n");
}
}
Output:
Checked out to: Guest 1
Comment: Comment by Guest 1
Date: 10/9/2003 8:58:02 AM
LocalSpec: C:\1\3
Machine: C1480406-A
Project: $/A
VersionNumber: 48
Checked out to: Guest 2
Comment: Comment by Guest 2
Date: 10/9/2003 6:22:10 AM
LocalSpec: C:\1
Machine: C1480400-A
Project: $/A
VersionNumber: 48
Number of Checkouts: 2
See Also
Reference
IVSSItem Interface
IVSSItem Members
Microsoft.VisualStudio.SourceSafe.Interop Namespace