SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a document library with versioning enabled. Documents are now in some other system and I need to migrate them. The problem is thath different verions migth have diffrente file types (doc, docx, pdf), but are still the same document. I guess you can't just change document extension and set new Content or am I wrong? Anybody have an experince with versions that have different document types/extensions?

Thanks for advices


Sample code:

var fic = new FileCreationInformation();
fic.Overwrite = true;
fic.Url = "1.png";
fic.Content = ReadByteArrayFromFile(@"e:\temp\1.png");
var f = dsvRoot.Files.Add(fic);


var items = dsv.GetItems(new CamlQuery());
ctx.Load(items, i => i.Include(ii => ii.Id));

items[0].File.SaveBinary(new FileSaveBinaryInformation() { Content = ReadByteArrayFromFile(@"e:\temp\1.jpg") });

items[0].File.MoveTo("/test/DSV/1.jpg", MoveOperations.Overwrite);

items[0].File.SaveBinary(new FileSaveBinaryInformation() { Content = ReadByteArrayFromFile(@"e:\temp\1.pdf") });

items[0].File.MoveTo("/test/DSV/1.pdf", MoveOperations.Overwrite);

items = dsv.GetItems(new CamlQuery());
ctx.Load(items, i => i.Include(ii => ii.Id, ii => ii.File, ii => ii.File.Versions));

It creates new versions, but the problem is that it renames old version files to the new one. So the content of v1 is PNG, but it's name is 1.pdf and it trys to open it as PDF. Any idea how to solve this?

share|improve this question
up vote 2 down vote accepted

Yeah, you can't really do that, as far as I know (and yes, this is fine in other EDRMSs) What I'd suggest is something like having 2 libraries - .doc and .pdf - and create lookup columns to refer between them.

I recognise that this means having 2 version histories - and that's not great - but SharePoint doesn't seem to deal with file type changes well.

share|improve this answer
I didn't want to hear that... Thanks – Andrej Cimperšek May 10 '11 at 13:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.