I have, from code, moved some images from different folders to one and I hoped that name conflicts whould be resolved by overwriting. That wasn't the case, instead there are two or more "versions" of the same file but with different ContentReferences. Then I want to delete the duplicated files that are not referenced by a page but I'm not sure which one that's used (it differs). When I remove an image in edit mode I get a warning if the image is used by a page, but from code I don't find a way to findout which pages that use a specific image. Does anyone know how to do that?
I think you could go with:
var softLinkRepos = ServiceLocator.Current.GetInstance<ContentSoftLinkRepository>();
var softLinks = softLinkRepos.Load(contentLink, true);
If I understood the question correct. :)
Thank you, I've tried the ContentSoftLinkRepository without success, I get 0 SoftLinks back. I'm testing with two images where one of them is used on a page. But both images and the page have 0 softlinks and I try three variants_contentSoftLinkRepository.Load(content.ContentGuid, true)_contentSoftLinkRepository.Load(content.ContentGuid, false)_contentSoftLinkRepository.Load(content.ContentLink).But no result from any of them.
Apperently there is a method on the IContentRepository called GetReferencesToContent. Try that one instead. :)
var references = ServiceLocator.Current.GetInstance<IContentRepository>().GetReferencesToContent(page.ContentLink, false);
That did the trick, thank you Erik!