Take a survey

API Quick Starts (Code Examples) > Repository Service API Quick Starts > Quick Start: Deleting a resource using the web service API

Quick Start: Deleting a resource using the web service API
The following C# code example deletes a resource called testResourceToBeDeleted in the repository.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.IO;
 
namespace RepositoryWebService
{
	class DeleteResource
	{
		[STAThread]
		static void Main(string[] args)
		{
            // This example will delete a resource from the LiveCycle ES repository.
            // First, a resource will be created and written to the repository.
            // That resource will then be deleted from the repository.
            try
			{
				//Create a RepositoryServiceService object
				RepositoryServiceService repositoryClient = new RepositoryServiceService();
				repositoryClient.Credentials = new System.Net.NetworkCredential("administrator", "password");
 
                // Specify the URI of the target folder for writing the resource
                String testFolderUri = "/testFolder";
 
                // Create the resource to be written to the folder
                Resource testResource = new Resource();
                testResource.id = new Id();
                testResource.lid = new Lid();
                testResource.name = "testResourceToBeDeleted";
                testResource.description = "test resource to be deleted";
 
                // Write the resource to the folder
                repositoryClient.writeResource(testFolderUri, testResource, null, null);
 
                // Retrieve the resource’ URI
                String resourceUri = testFolderUri + "/" + testResource.name;
 
                // Retrieve the resource to verify that it was successfully written
                Resource r = repositoryClient.readResource(resourceUri, null, null);
 
			    // Print the resource verification message
			    Console.WriteLine("Resource " + resourceUri + " was successfully written.");
 
                // Delete the resource
                string[] uris = new string[1];
                uris[0] = resourceUri;
                repositoryClient.deleteResources(uris, null);
 
			    // Verify that the resource has been deleted 
			    try {
 
				    // Attempt to read the nonexistent resource,
				    // which will cause an exception if the resource was deleted.
				    BLOB doc = repositoryClient.readResourceContent(resourceUri, null);
 
			    } catch (Exception re) {
 
				    // Indicate successful deletion
                    Console.WriteLine("Resource " + resourceUri + " was successfully deleted.");
			    }
            }
			catch (Exception e)
			{
                Console.WriteLine(
                    "Exception thrown while trying to delete the resource" + 
                    e.Message
                );
			}
			
		}
	}
}
 
 
 
 

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/quickStarts_Repository.18.20.html