Quick Start (Base64): Deleting a resource using the web service API

The following C# code xample deletes Loan.xdp from Applications/FormsApplication/1.0/FormsFolder. If this XDP file is not located in this folder, an exception is thrown. (See Deleting Resources.)

/* 
    * Ensure that you create a .NET client assembly that uses  
    * base64 encoding. This is required to populate a BLOB  
    * object with data or retrieve data from a BLOB object. 
    *  
    * For information, see "Invoking LiveCycle using Base64 Encoding"  
    * in Programming with LiveCycle 
    */ 
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 deletes Loan.xdp from /Applications/FormsApplication/1.0/FormsFolder/ 
              try 
               { 
                   //Create a RepositoryServiceService object 
                   RepositoryServiceService repositoryClient = new RepositoryServiceService(); 
                   repositoryClient.Credentials = new System.Net.NetworkCredential("administrator", "password"); 
 
                   // Specify the URI of the target folder from which the resource is deleted 
                   String resourceUri = "/Applications/FormsApplication/1.0/FormsFolder/Loan.xdp"; 
 
                   // 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 
                   ); 
               } 
 
           } 
       } 
}