IVSSItem.UndoCheckout Method 

Implements undo checkout of a checked-out file or a checked-out project.

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

Syntax

'Declaration
Sub UndoCheckout ( _
    <InAttribute> <OptionalAttribute> Optional Local As String = "", _
    <InAttribute> <OptionalAttribute> Optional iFlags As Integer = 0 _
)
'Usage
Dim instance As IVSSItem
Dim Local As String
Dim iFlags As Integer

instance.UndoCheckout(Local, iFlags)
void UndoCheckout (
    [OptionalAttribute] [InAttribute] string Local,
    [OptionalAttribute] [InAttribute] int iFlags
)
void UndoCheckout (
    [InAttribute] [OptionalAttribute] String^ Local, 
    [InAttribute] [OptionalAttribute] int iFlags
)
void UndoCheckout (
    /** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ String Local, 
    /** @attribute InAttribute() */ /** @attribute OptionalAttribute() */ int iFlags
)
function UndoCheckout (
    Local : String, 
    iFlags : int
)

Parameters

  • Local
    Optional. A string representing a fully qualified local path from which you want to undo the checkout. The default value, null, represents a folder to which the file or the project was checked out.
  • iFlags
    Optional. The default value is 0. For more information, see VSSFlags.

Remarks

[IDL]

HRESULT UndoCheckout ([in,defaultvalue(0)]BSTR Local, [in,defaultvalue(0)]long iFlags);

Note

When you undo check out, you lose all changes that you made to your local copies since the last checkout.

Example

The following example demonstrates how to use the UndoCheckout method to undo checkout of a file. In this example the file, test.txt, is checked out and modified. Undo checkout is then performed. The content of the file must not change in the SourceSafe database.

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

public class IVSSTest
{
    public static void Main()
    {
        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, ""); 

        IVSSItem vssFile = vssDatabase.get_VSSItem(testFile, false);

        vssFile.Checkout("Checkout comment", @"C:\1\test.txt", 0); 

        if((VSSFileStatus)vssFile.IsCheckedOut == 
           VSSFileStatus.VSSFILE_NOTCHECKEDOUT)
            Console.WriteLine(vssFile.Spec +  " is not checked out.");
        else
            Console.WriteLine(vssFile.Spec +  " is checked out.");

        Console.WriteLine("Now alter the file and press any key.");
        Console.ReadLine();

        vssFile.UndoCheckout(@"C:/1/test.txt", 0);

        if((VSSFileStatus)vssFile.IsCheckedOut == 
           VSSFileStatus.VSSFILE_NOTCHECKEDOUT)
            Console.WriteLine(vssFile.Spec +  ": undo checkout is completed. ");
        else
            Console.WriteLine(vssFile.Spec +  " is checked out.");
    }
}

Output:

$/TestFolder/test.txt is checked out.

Now alter the file and press any key.

$/TestFolder/test.txt: undo checkout is completed.

See Also

Reference

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