Let’s see, How to delete
particular document version from SharePoint document library.
private void DeleteVersion(){try{DialogResult dr = MessageBox.Show("Are you sure tou want to send this version to the site Recycle bin?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);if (dr == DialogResult.Yes){SPSite Site = new SPSite(requestUrl);using (SPWeb web = Site.OpenWeb()){SPList list = web.Lists[DocLibrary];SPListItem item = list.GetItemById(DocID);SPListItemVersionCollection Fileversioncollection = item.Versions;SPListItemVersion version = Fileversioncollection.GetVersionFromID(selectedversionID);version.Recycle();MessageBox.Show("Document version has been successfully deleted.", "Message");}}}catch (Exception ex){MessageBox.Show(ex.Message, "Message");return;}}
No comments:
Post a Comment