以下代码可以用来获取文档的上一个major version, 并且复制内容到另一document library。

using (SPWeb web = new SPSite("http://emiliu:8081/team2").OpenWeb())
{
    SPFile file = web.GetFile("http://emiliu:8081/team2/Pages/original page.aspx");
               
    //Get all version
    SPFileVersionCollection versions = file.Versions;
    

  //Get previous published version SPFileVersion version = versions[versions.Count - 1];
  

  //
Get the data byte[] dBytes = version.OpenBinary();

  //Copy the page to the other library with the name "test.aspx" web.Files.Add("http://emiliu:8081/team2/documentlibrary/test.aspx", dBytes); }

Done。

posted on 2013-05-24 13:40  Liu_Liu  阅读(182)  评论(0编辑  收藏  举报