Mediaservice - how do I update an existing file programmatically

Hi Guys,

I feel like I’ve been banging my head against a wall,

I can quite happily create and save the file using the MediaService with the code below:

var ms = ApplicationContext.Current.Services.MediaService;
                            IMedia mimage = ms.CreateMedia(model.attachment.FileName, -1, "Image");
                            mimage.SetValue(Constants.Conventions.Media.File, model.attachment);
                            ms.Save(mimage);

When I run the code above I will have a file with the following path ‘/media/1234/image.jpg’ for example.

I want to be able to update this keeping the same file directory e.g. ‘/media/1234/updatedimage.jpg’ using the mediaservice, is this possible? or do I need to use System.IO?

Thanks

Darren


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/85566-mediaservice-how-do-i-update-an-existing-file-programmatically