This is only part solution, because You need to find how you will take files from mediaa library by its url, and then delete them. You can find this in
Media library solution
using CMS.Base;
using CMS.CustomTables;
using CMS.DataEngine;
using CMS.DocumentEngine;
[CustomTableEvents]
public partial class CMSModuleLoader
{
/// <summary>
/// Attribute class that ensures the loading of custom handlers.
/// </summary>
private class CustomTableEventsAttribute : CMSLoaderAttribute
{
/// <summary>
/// The system executes the Init method of the CMSModuleLoader attributes when the application starts.
/// </summary>
public override void Init()
{
// Assigns custom handlers to events
ObjectEvents.Delete.Before+= Delete_Before;
}
private void Delete_Before(object sender, ObjectEventArgs e)
{
switch (e.Object.TypeInfo.ObjectType)
{
case "customtableitem.yournamespace.yourclassname":
/* do your work here, you need to take media files from media library which are
in your custom table and to delete the files from media library, before you
delete the custom table.
*/
break;
default:
break;
}
}
}
}