Share via


IVSSItem.Deleted Property 

Gets or sets a value indicating whether a particular file or a project is deleted.

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

Syntax

'Declaration
Property Deleted As Boolean
'Usage
Dim instance As IVSSItem
Dim value As Boolean

value = instance.Deleted

instance.Deleted = value
bool Deleted { get; set; }
property bool Deleted {
    bool get ();
    void set ([InAttribute] bool pbDeleted);
}
/** @property */
boolean get_Deleted ()

/** @property */
void set_Deleted (/** @attribute InAttribute() */ boolean pbDeleted)
function get Deleted () : boolean

function set Deleted (pbDeleted : boolean)

Property Value

true if file or project marked as deleted, otherwise false.

Remarks

[IDL]

HRESULT Deleted ([out,retval]boolean *pbDeleted);

HRESULT Deleted ([in]boolean bDeleted);

The Deleted property applies to both files and projects. When a project is deleted, all of its files and subprojects are deleted as well.

Example

The following example demonstrates how to use the Deleted property to verify if the project folder and the files residing in it are deleted. It also demonstrates how to delete a file (mark as "deleted"). For test purposes, the TestFolder project contains one deleted file, test1.txt, and two files which are not deleted, test2.txt and test3.txt. The test3.txt file is deleted by the program. When you open SourceSafe, the test3.txt file will not appear in SourceSafe Explorer. Recover test3.txt in SourceSafe Explorer in order to run this example again.

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 IVSSItem references to project and files objects.
        VSSItem vssProject = vssDatabase.get_VSSItem("$/TestFolder", false);
        IVSSItem vssFile1 = 
                 vssDatabase.get_VSSItem("$/TestFolder/test1.txt", true);
        IVSSItem vssFile2 = 
                 vssDatabase.get_VSSItem("$/TestFolder/test2.txt", false);
        IVSSItem vssFile3 = 
                 vssDatabase.get_VSSItem("$/TestFolder/test3.txt", false);

        // Test whether or not the project and the files are deleted.
        if(vssProject.Deleted)            
            Console.WriteLine(vssProject.Name + " is deleted.");
        else    
            Console.WriteLine(vssProject.Name + " is not deleted.");
        if(vssFile1.Deleted)            
            Console.WriteLine(vssFile1.Name + " is deleted.");
        else    
            Console.WriteLine(vssFile1.Name + " is not deleted.");
        if(vssFile2.Deleted)
            Console.WriteLine(vssFile2.Name + " is deleted.");
        else    
            Console.WriteLine(vssFile2.Name + " is not deleted.");

        // Mark test3.txt as "Deleted". When you open SourceSafe
        // test3.txt will be deleted. Recover this file in
        // SourceSafe Explorer before running this example again.
        Console.WriteLine(vssFile3.Name + " is not deleted. Mark as deleted.");
        vssFile3.Deleted = true;
        Console.WriteLine(vssFile3.Name + " has been marked as deleted.");            
    }
}

Output:

TestFolder is not deleted.

test1.txt is deleted.

test2.txt is not deleted.

test3.txt is not deleted. Mark as deleted.

test3.txt has been marked as deleted.

See Also

Reference

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