Versions.DeleteVersion Method (Versions)
Versions.DeleteVersion Method (Versions)
Deletes the specified file version.

Web Service: VersionsWeb Reference: http://<Site>/_vti_bin/Versions.asmx
Syntax

'Usage

Dim instance As Versions
Dim fileName As String
Dim fileVersion As String
Dim returnValue As XmlNode

returnValue = instance.DeleteVersion(fileName, fileVersion)

'Declaration

<SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/DeleteVersion", RequestNamespace:="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace:="http://schemas.microsoft.com/sharepoint/soap/", Use:=SoapBindingUse.Literal, ParameterStyle:=SoapParameterStyle.Wrapped)> _
Public Function DeleteVersion ( _
    fileName As String, _
    fileVersion As String _
) As XmlNode

Parameters

fileName

A string that contains the site-relative location of the folder name and file name of the file whose version is to be deleted.

fileVersion

A string that specifies the number of the file version to delete.

Return Value

An XML fragment in the following form that can be assigned to a System.Xml.XmlNode object:
<results xmlns="http://schemas.microsoft.com/sharepoint/soap/">
   <list id="{26E516B0-8241-4B97-984D-000000000000}" />
   <versioning enabled="1" /><settings url="http://Server_Name/
         Site_Name/_layouts/1033/LstSetng.aspx?
      List={26E516B0-8241-4B97-984D-000000000000}" />
   <result version="@5" url="http://Server_Name/Site_Name/
         Shared Documents/File_Name.doc" 
      created="6/7/2003 6:28 PM" createdBy="DOMAIN\User" size="19968" 
         comments="" />
   <result version="1" url="http://Server_Name/Site_Name/
      _vti_history/1/Shared Documents/File_Name.doc" 
      created="6/7/2003 5:49 PM" createdBy="DOMAIN\User" size="19968" 
         comments="" />
      .
      .
      .
</results>
Remarks

The fileName parameter provides both file name and relative folder location, in the form folder_name/file_name. Following are examples of this parameter:

  • document_library/file_name.ext

  • Shared Documents/File_Name.doc

Example

The following code example deletes the third version of a specified file.

This example requires that a using (C#) or Imports (Microsoft Visual Basic) directive be included for the System.Xml namespace.

Dim versionService As New Web_Reference_Folder_Name.Versions()
versionService.Credentials = 
   System.Net.CredentialCache.DefaultCredentials

Dim ndVersions As XmlNode = 
   versionService.DeleteVersion("Shared Documents/File_Name", "3")

MessageBox.Show(ndVersions.OuterXml)

See Also

© 2010 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View