Version history

Asked

Viewed 48 times

0

It is possible to identify in which version of a file (which has versioning), is determined assumed or word??

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

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

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

While searching, I was wondering where the word "Test 2" is. Is it version 1 or version 2? Which in this case is version 1.

  • Dani, can you print ? Or what version of Sharepoint?

1 answer

0

Hey, there, 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

  • K2rt'O4, I thought I didn’t need to customize .... I thought I had some native configuration. Thanks for the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.