In this article, I am going show how to open
particular version document from SharePoint document library.
void ViewDocument()
{
try{SPSite Site = new SPSite(URL);using (SPWeb web = CurrentSite.OpenWeb()){SPList Selectedlist = web.Lists[DocLibrary];SPListItem item = Selectedlist.GetItemById(DocID);SPFileVersion ver = item.File.Versions.GetVersionFromID(versionID);Stream steam = ver.OpenBinaryStream();byte[] binfile = ver.File.OpenBinary();FileStream fstream = new FileStream(filePath + "\\" + item.File.Name,FileMode.Create, FileAccess.ReadWrite);fstream.Write(binfile, 0, binfile.Length);fstream.Close();frm_ViewAttachment.Close();Process.Start(filePath + "\\" + item.File.Name);}}catch (Exception ex){MessageBox.Show(ex.Message, "Message");return;}}
Thanks for sharing...
ReplyDelete