0

How do i get file of one of previous version using client object model. With code I am getting Microsft.sharepoint.client.FileVersion object as expected.

But trying to do Web.GetFileByServerRelativeUrl(FileVersion.Url) fails.

In server object model , I am aware, we can use SPFileVersion.OpenBinaryStream()

Looking for client object mode solution.

I get error as "File not found" when I provide relative url.

There is apparently nothing wrong with relative url format as it works for normal get file for any other files except version files.

Mandar Jogalekar
  • 3,199
  • 7
  • 44
  • 85

1 Answers1

0

I Solved this by ussing WebClient to download file data. there are no sharepoint client object model methods available for the purpose. this works.

public static byte[] GetByteArrayFromVersionFile(Web web,string fileVersionUrl)
        {
            WebClient wc = new WebClient();
            wc.UseDefaultCredentials = true;
            wc.Headers.Add("user-agent", " Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0");
            byte[] content = wc.DownloadData(web.Url + "/" + fileVersionUrl);
            return content;

        }
Mandar Jogalekar
  • 3,199
  • 7
  • 44
  • 85