Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to implement a method that retrieve a "file version" that will must be the same of the parameter number I'm going o pass.

SPListItem item = attachments.First();

                                                 var ultimaVersione = (from SPListItemVersion ver in item.Versions where ver.IsCurrentVersion select ver).First();                         

                                                 var tutteLeVersioni = item.File.Versions;

                                                 var versioni = new int[tutteLeVersioni.Count];
                                                 for (int i = 0; i <= versioni.Length; i++ )
                                                 {  
                                                     if(tutteLeVersioni[i].ID== getFileObj.versionNumber)
                                                     {
                                                         tutteLeVersioni.RestoreByID(tutteLeVersioni[i].ID);
                                                         files.Add(new fileList() { file = tutteLeVersioni[i].File.OpenBinary() });
                                                         tutteLeVersioni.RestoreByID(ultimaVersione.VersionId);
                                                         found = true;
                                                     }
                                                 }

I've been trying restoring the file with the chosen version, and then retrieve it. But I noticed that with the method "RestoreByID()", it it puts one more version Item inside the Item. Some idea???

share|improve this question
    
Please clarify the question. Is it to find out how to obtain the particular copy of the version through code? Is it the code to Restore the version? Is it something else? Also, I'd recommend doing a file restore through the SharePoint User Interface to see the experience you get, then that may help in translating to what you are seeing in code. –  Brian Mar 23 '12 at 13:27
    
Hi Brian.I 'm trying to obtain a particular copy of file of a specific version, through code –  Bruno Ferreira Mar 23 '12 at 13:31
    
Please edit the question to clarify this. For example: "My question is, using the Server Side SharePoint API, how can I retrieve a file version given the version's history id?" –  Brian Mar 23 '12 at 13:52
    
Ciao. Sto implementando un metodo che mi consenta di recuperare la copia del file che ha un specifico ID version. Se chiamo la proprietà "file" di SPFileVersion, mi ritorna sempre il "parent file object", cioè il contenuto del file è sempre quello più aggiornato. Vorrei poter recuperare il contenuto del file della versione specificata. –  Bruno Ferreira Mar 23 '12 at 14:18

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.