IVSSItem.Destroy MethodÂ
Permanently removes deleted files, non-deleted files, deleted projects, or non-deleted projects from the SourceSafe database.
Namespace: Microsoft.VisualStudio.SourceSafe.Interop
Assembly: Microsoft.VisualStudio.SourceSafe.Interop (in microsoft.visualstudio.sourcesafe.interop.dll)
Syntax
'Declaration
Sub Destroy
'Usage
Dim instance As IVSSItem
instance.Destroy
void Destroy ()
void Destroy ()
void Destroy ()
function Destroy ()
Remarks
[IDL]
HRESULT Destroy ();
When you destroy a file or a project, you cannot recover it. When calling the Destroy method of a project, all of its subprojects and files are destroyed as well.
Example
The following example demonstrates how to use the Destroy method to permanently remove a file from the SourceSafe database.
[C#]
using System;
using Microsoft.VisualStudio.SourceSafe.Interop;
public class IVSSTest
{
public static void Main()
{
string testFolder = "$/TestFolder";
string testFile = @"C:\VSSTestWF\TestFolder\fileAdd.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, "");
// Create a VSSItem specifying the desired folder.
VSSItem vssFolder = vssDatabase.get_VSSItem(testFolder, false);
// Display folder contents prior to adding a file.
DisplayFolderContent(vssFolder);
// Add a file to the project.
VSSItem vssTestFile = vssFolder.Add(testFile, "Adding a new file", 0);
// Display folder contents after adding a file.
DisplayFolderContent(vssFolder);
// Destroy the new file.
vssTestFile.Destroy();
// Display folder contents after destroying the new file.
DisplayFolderContent(vssFolder);
}
private static void DisplayFolderContent(IVSSItem vssFolder)
{
Console.Write("\n{0} contains:", vssFolder.Spec);
foreach(VSSItem vssItem in vssFolder.get_Items(false))
Console.Write(" {0}", vssItem.Name);
}
}
Output:
$/TestFolder contains: file1.txt file2.txt
$/TestFolder contains: fileAdd.txt file1.txt file2.txt
$/TestFolder contains: file1.txt file2.txt
See Also
Reference
IVSSItem Interface
IVSSItem Members
Microsoft.VisualStudio.SourceSafe.Interop Namespace