Remove downloadable files from a product

To remove a downloadable file form a product, you must perform the following:

  1. Get instances of the following managers:
    • Catalog manager
    • Content links manager
  2. Get the specified product.
    Get an instance of the specified product. For more information, see For developers: Query products.
  3. Get the product file.
    Get the instance of the product file from the Files collection.
  4. Remove the product file.
    Remove the ProductFile instance from the Files collection.
  5. Save the product.
    Save the changes to the catalog manager.
  6. Get the content link.
    Get the content link for the product and the file.
  7. Mark the content link to be deleted.
    To mark the content link to be deleted, call the Delete method of the content links manager and pass the content link as an argument.
  8. Delete the content link.
    To delete the content link, save the changes to the content links manager.

NOTE: For more information about how to delete a file from the Downloadable goods library, see For developers: Delete documents. Note that you have to use the libraries manager with the system libraries provider. Before deleting the file, make sure that it is removed form the product and the content link between them is deleted.

Use the following code sample:

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?