Delete/Share file

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
rajeev
Posts: 1
Joined: Tue Mar 27, 2007 11:54 pm

Delete/Share file

Post by rajeev » Wed Mar 28, 2007 12:07 am

Hi All,
I am trying to write code in C# using vault client libraries to delete and share file.
Following code snippet is for deleting a file. I don't know why after successful execution of code, still the file is not getting deleted. I also tried with file's ID instead of ObjVerID.

Code: Select all

VaultClientFile currentFile = (VaultClientFile)fileArray[index];
                        ChangeSetItem_DeleteFile deleteFile = new ChangeSetItem_DeleteFile(VaultDateTime.Now, "Deleting it as this is not shared", string.Empty, currentFile.ObjVerID, currentFile.FullPath);
                        ChangeSetItemColl changeSetColl = new ChangeSetItemColl();
                        changeSetColl.Add(deleteFile);
                        vaultClient.Commit(changeSetColl);// vaultClient is object of VaultClientOperationsLib.ClientInstance

Any pointer will of help.
Thanks in advance.
Rajeev

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Wed Mar 28, 2007 7:44 am

The call to commit will return a bool that informs you if the server rejected the request. To add a listener to the clientInstance, do this:

Code: Select all

if ( client.ClientInstance != null )
			{
				client.ClientInstance.EventEngine.addListener(this, typeof(MessageEvent));
				client.ClientInstance.EventEngine.addListener(this, typeof(BulkMessageEvent));
			}
You will also need to define the handlers for the MessageEvent and BulkMessageEvent

Code: Select all

public void HandleEvent(MessageEvent e)
		{
			//This is where you can print out the error messages from the MessageEvent
		}
		public void HandleEvent(BulkMessageEvent e)
		{
			//This is where you can print out the error messages from the BulkMessageEvent
		}

Post Reply