This DTO has been deprecated as part of the Relativity Services API (RSAPI) Deprecation and is no longer supported. For more information and alternative APIs, see RSAPI deprecation process.

Folder

Within a Relativity workspace, you can use folders to organize content. For more information, see the RelativityOne Documentation site.

The Services API supports perform create, read, delete, and query operations on a Folder DTO.

Note: You can also create, read, and delete folders using the single-artifact methods common to all Relativity DTOs. For more information, see Single-artifact access.

This page contains the following information:

Create a Folder

You can use the Create() method on the Folder repository to add a new folder to Relativity as illustrated in this code sample.

public static bool Create_Folder_Using_Repository(IRSAPIClient proxy)
{
     //STEP 1: Create a Folder object.
     DTOs.Folder folder = new DTOs.Folder { ParentArtifact = new DTOs.Artifact(1003697), Name = "My New Folder" };
      
     //STEP 2: Set Folder properties.
     //STEP 3: Create the Folder.
     DTOs.WriteResultSet<DTOs.Folder> results;
     try
     {
          results = proxy.Repositories.Folder.Create(folder);
     }
     catch (Exception ex)
     {
          Console.WriteLine("An error occurred: {0}", ex.Message);
          return false;
     }
      
     //STEP 4: Check for success.
     if (!results.Success)
     {
          Console.WriteLine("Error: " + results.Message);
          return false;
     }
     else
     {
          Console.Write("Folder created successfully.");
     }
     return true;
}
        

Read a Folder

To read Field values on a Folder, you can use the Read() method on the Folder repository as illustrated in this code sample.

public static bool Read_Folder_Using_Repository(IRSAPIClient proxy)
{
     // STEP 1: Read current values.
     Folder requestArtifact = new Folder(1003697);
     requestArtifact.Fields.Add(new FieldValue(FolderFieldNames.Name));
      
     ResultSet<Folder> readResult1;
      
     try
     {
          readResult1 = proxy.Repositories.Folder.Read(requestArtifact);
     }
     catch (Exception ex)
     {
          Console.WriteLine(string.Format("An error occurred while reading the folder: {0}", ex.Message));
          return false;
     }
      
     if (!readResult1.Success)
     {
          Console.WriteLine("Error reading the folder: " + readResult1.Message);
          return false;
     }
      
     // STEP 2: Get the folder from the read results.
     Folder readArtifact = readResult1.Results.FirstOrDefault().Artifact;
      
     if (readArtifact == null)
     {
          Console.WriteLine("There is no folder with ArtifactID 1038603");
          return false;
     }
     else
     {
          Console.WriteLine(String.Format("ArtifactID:{0} ParentArtifactID:{1} - {2}", readArtifact.ArtifactID, 
               readArtifact.ParentArtifact.ArtifactID, readArtifact.Name));
     }
     return true;
}
        

Delete a Folder

You can use the Delete() method on a Folder repository to remove it as illustrated in this code sample.

public static bool Delete_Folder_Using_Repository(IRSAPIClient proxy)
{
     // STEP 1: Read current values.
     DTOs.Folder requestArtifact = new Folder(1036275);
      
     ResultSet<DTOs.Folder> readResult1;
      
     try
     {
          readResult1 = proxy.Repositories.Folder.Read(requestArtifact);
     }
     catch (Exception ex)
     {
          Console.WriteLine(string.Format("An error occurred while reading the folder: {0}", ex.Message));
          return false;
     }
      
     if (!readResult1.Success)
     {
          Console.WriteLine("Error reading the folder: " + readResult1.Message);
          return false;
     }
      
     // STEP 2: Get the folder from the read results.
     DTOs.Folder readArtifact = readResult1.Results.FirstOrDefault().Artifact;
     if (readArtifact == null)
     {
          Console.WriteLine("There is no folder with ArtifactID 1037993");
          return false;
     }
     // STEP 3: Delete the folder.
     WriteResultSet<DTOs.Folder> deleteResult;
      
     try
     {
          deleteResult = proxy.Repositories.Folder.Delete(requestArtifact);
     }
     catch (Exception ex)
     {
          Console.WriteLine("An error occurred deleting the folder: {0}", ex.Message);
          return false;
     }
      
     if (!deleteResult.Success)
     {
          Console.WriteLine("Error deleting the folder: " + deleteResult.Message);
          return false;
     }
     // STEP 4: To confirm the deletion, try to find the folder again.
     // Since the folder doesn't exist, the read operation fails. (ResultSet.Success is set to false).
     // You can query for the folder's ArtifactID. The result is Success with 0 results.
     WholeNumberCondition artifactIDCondition = 
          new WholeNumberCondition(ArtifactQueryFieldNames.ArtifactID, NumericConditionEnum.EqualTo, 1037993);
      
     DTOs.Query<DTOs.Folder> query = new DTOs.Query<DTOs.Folder>
     {
          Condition = artifactIDCondition
     };
      
     QueryResultSet<DTOs.Folder> queryResult;
      
     try
     {
          queryResult = proxy.Repositories.Folder.Query(query);
     }
     catch (Exception ex)
     {
          Console.WriteLine("An error occurred querying the folder after it was deleted: {0}", ex.Message);
          return false;
     }
      
     if (queryResult.Success)
     {
          if (queryResult.Results.Count == 0)
               Console.WriteLine("Delete succeeded, the folder has been deleted");
     }
     else
     {
          Console.WriteLine("Error querying the folder after deletion: " + queryResult.Message);
          return false;
     }
     return true;
}
        

Query for a Folder

To query for a Folder, you can use the fields listed in the following table. For more information, see Search Relativity.

Fields for Folder queries
Artifact ID System Created By
Name System Created On
Parent Artifact ID System Last Modified By
Parent Artifact Name System Last Modified On

The following sample code illustrates how to query for Folder DTOs using a repository.

public static bool Query_Folder_Using_Repository(IRSAPIClient proxy)
{
     // STEP 1: Create the query.
     Query<Folder> query = new Query<kCura.Relativity.Client.DTOs.Folder>();
     query.Fields.Add(new FieldValue(FolderFieldNames.Name));
     ResultSet<Folder> readResult1;
      
     // STEP 2: Query for the folders.
     try
     {
          readResult1 = proxy.Repositories.Folder.Query(query);
     }
     catch (Exception ex)
     {
          Console.WriteLine(string.Format("An error occurred while querying for the folder: {0}", ex.Message));
          return false;
     }
      
     if (!readResult1.Success)
     {
          Console.WriteLine("Error reading the folder: " + readResult1.Message);
          return false;
     }
      
     // STEP 3: Use the results.
     foreach (Result<Folder> folder in readResult1.Results)
     {
          Console.WriteLine(String.Format("ArtifactID:{0} ParentArtifactID:{1} - {2}", 
               folder.Artifact.ArtifactID, folder.Artifact.ParentArtifact.ArtifactID, folder.Artifact.Name));
     }
     return true;
}
        

Additional Resources

DevHelp Community GitHub Release Notes NuGet

Share knowledge with the Relativity developer community.

Access tools and resources to build an application.

Review the most recent product release notes.

Create .NET Apps faster with NuGet.