Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi all
I have a .ascx control in C# that should delete selected media items and a node by their id's.
I can't seem to find either Document.Delete or Node.Delete anywhere in intellisense.
Can anyone point me in the right direction for this?
Many thanks
Shaun
I think i've worked it out.
Document thisDoc = new Document(intID); thisDoc.delete();
Ahh. Unfortunately that didn't delete anything.
Also, when I try to go into admin and right-click delete the media items I'm told
Delete failed with the following error The process cannot access the file because it is being used by another process.
Any ideas?
Have you tried
using umbraco.cms.businesslogic.media;...Document thisMedia = new Media(intID);thisMedia.delete();
oops, should be...
using umbraco.cms.businesslogic.media;...Media thisMedia = new Media(intID);thisMedia.delete();
Brilliant. Thanks RDNZL
Hi Guys
Anyone having trouble with Umbraco 8. Here is how I do it.
public void DeleteMedia(int mediaId) { try { IMedia media = _mediaService.GetById(mediaId); if(media != null) _mediaService.Delete(media); } catch (Exception e) { _logger.Error<UmbMediaService>("DeleteMedia | Exception: {0} | Message: {1}", e.InnerException != null ? e.InnerException.ToString() : "", e.Message != null ? e.Message.ToString() : ""); } }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Deleting media items and nodes programatically
Hi all
I have a .ascx control in C# that should delete selected media items and a node by their id's.
I can't seem to find either Document.Delete or Node.Delete anywhere in intellisense.
Can anyone point me in the right direction for this?
Many thanks
Shaun
I think i've worked it out.
Ahh. Unfortunately that didn't delete anything.
Also, when I try to go into admin and right-click delete the media items I'm told
Delete failed with the following error The process cannot access the file because it is being used by another process.
Any ideas?
Have you tried
oops, should be...
Brilliant. Thanks RDNZL
Hi Guys
Anyone having trouble with Umbraco 8. Here is how I do it.
is working on a reply...