Hi,
I'm trying to delete an image from the media library using codebehind. I'm trying to overwrite that image so I'm trying to delete it first. But I'm getting an error:
The object with code name '87556833-1f14-4aef-b370-ba955c2f023a' already exists. 
I used this code:
MediaFileInfoProvider.DeleteMediaFile(CMSContext.CurrentSiteID, libraryInfo.LibraryID, path, false);
            // delete file if it exists
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            using (var newFile = new FileStream(path, FileMode.Create))
            {
                newFile.Write(buffer, 0, buffer.Length);
            }
            //create media file info item
            var fileInfo = new MediaFileInfo(path, libraryInfo.LibraryID, "NCDA")
            {
                FileTitle = fileName,
                FileDescription = "",
            };
            // Save media file info
            try
            {
               MediaFileInfoProvider.ImportMediaFileInfo(fileInfo);
            }
            catch { }
I checked the database and no table seems to actually have this GUID stored anywhere. Really strage.
Is there any way that I can replace an image from the media library using asp.net code?
Thanks.