2

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

edit:

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);

ctx.Load(f);
ctx.ExecuteQuery();

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

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

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

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

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

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

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?

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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