Version History

0

Is it possible to identify in which version of a file (which has versioning), is determined sign or word ??

For example, there are 2 versions of the Test document, where:

  

version 1, has the text: "Test 1, Test 2 and Test 3".

     

version 2, has the text: "Test 1 and Test 3".

When doing the search, I wanted to know where the word "Test 2" is. Is it version 1 or version 2? Which in this case is in version 1.

    
asked by anonymous 22.12.2016 / 14:32

1 answer

0

Hello, Dani. With the code snippet below you will be able to read the contents of each version of a file within a library.

foreach (SPSite tmpSite in tmpRootColl)
            {
                foreach (SPWeb tmpWeb in tmpSite.AllWebs)
                {
                    foreach (SPList tmpList in tmpWeb.Lists)
                    {
                        if (tmpList.BaseType == SPBaseType.DocumentLibrary & tmpList.Title == "Docs")
                        {
                            foreach (SPListItem tmpSPListItem in tmpList.Items)
                            {
                                if (tmpSPListItem.Versions.Count > 0)
                                {
                                    SPListItemVersionCollection tmpVerisionCollection = tmpSPListItem.Versions;

                                    SPFile tmpFile = tmpWeb.GetFile(tmpWeb.Url + "/" + tmpSPListItem.File.Url);

                                    foreach (SPFileVersion tmpSPFileVersion in tmpFile.Versions)
                                    {
                                        StreamReader reader = new StreamReader(tmpSPFileVersion.OpenBinaryStream());
                                        string textoDoc = reader.ReadToEnd();
                                    }
                                }
                            }
                        }
                    }
                }
            }

Run some tests and modify as needed. I think you can start from this code there.

Abs

    
26.12.2016 / 15:19