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'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)
                                                         files.Add(new fileList() { file = tutteLeVersioni[i].File.OpenBinary() });
                                                         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 – hello B 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. – hello B Mar 23 '12 at 14:18

Your Answer


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

Browse other questions tagged or ask your own question.