Versions.RestoreVersion Method
Restores the specified file version.
Namespace: [Versions Web service]
Web service reference: http://Site/_vti_bin/Versions.asmx
Syntax
'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/RestoreVersion", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/", _
ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function RestoreVersion ( _
fileName As String, _
fileVersion As String _
) As XmlNode
'Usage
Dim instance As Versions
Dim fileName As String
Dim fileVersion As String
Dim returnValue As XmlNode
returnValue = instance.RestoreVersion(fileName, _
fileVersion)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/RestoreVersion", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/",
ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public XmlNode RestoreVersion(
string fileName,
string fileVersion
)
Parameters
fileName
Type: System.StringA string that contains the site-relative URL of the file in the form Folder_Name/File_Name.
fileVersion
Type: System.StringA string that identifies the file version.
Return Value
Type: System.Xml.XmlNode
An XML fragment in the following form that can be assigned to a System.Xml.XmlNode object:
<results xmlns="https://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_Alias"
size="19968" comments="" />
<result version="1" url="http://Server_Name/Site_Name/
Shared Documents/File_Name.doc"
created="6/7/2003 5:49 PM" createdBy="DOMAIN\User_Alias"
size="19968" comments="" />
<result version="2" url="http://Server_Name/Site_Name/
Shared Documents/File_Name.doc"
created="6/7/2003 5:49 PM" createdBy="DOMAIN\User_Alias"
size="19968" comments="" />
<result version="3" url="http://Server_Name/Site_Name/
Shared Documents/File_Name.doc"
created="6/7/2003 5:50 PM" createdBy="DOMAIN\User_Alias"
size="19968" comments="" />
<result version="4" url="http://Server_Name/Site_Name/
Shared Documents/File_Name.doc"
created="6/7/2003 5:55 PM" createdBy="DOMAIN\User_Alias"
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
Examples
The following code example restores the first version of a file in a document library.
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.RestoreVersion("Shared Documents/File_Name.doc", "1")
Web_Reference_Folder_Name.Versions versionService =
new Web_Reference_Folder_Name.Versions();
versionService.Credentials=
System.Net.CredentialCache.DefaultCredentials;
XmlNode ndVersions =
versionService.RestoreVersion("Shared Documents/File_Name.doc","1");