Imaging.Rename Method
Renames the specified files (items) in a list on the current Web site.
Namespace: [Imaging Web service]
Web service reference: http://Site/_vti_bin/Imaging.asmx
Syntax
'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/ois/Rename", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/ois/", _
ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/ois/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function Rename ( _
strListName As String, _
strFolder As String, _
request As XmlElement _
) As XmlNode
'Usage
Dim instance As Imaging
Dim strListName As String
Dim strFolder As String
Dim request As XmlElement
Dim returnValue As XmlNode
returnValue = instance.Rename(strListName, _
strFolder, request)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/ois/Rename", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/ois/",
ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/ois/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public XmlNode Rename(
string strListName,
string strFolder,
XmlElement request
)
Parameters
strListName
Type: System.StringThe name of the list within the current Web site.
strFolder
Type: System.StringThe relative path from the root of the list to the target folder.
request
Type: System.Xml.XmlElementThe files to rename and the new base name. For example, to rename "tree.jpg" to "forest.jpg", the request parameter might resemble the following.
<Request> <files> <file filename="tree.jpg" newbasename="forest"/> . . . </files> </Request>
Return Value
Type: System.Xml.XmlNode
A Microsoft.SharePoint.SoapServer.SoapXml object that contains the following.
<results xmlns="https://schemas.microsoft.com/sharepoint/soap/ois/">
<result name="oldFileName0" renamed="true"
newbasename="newBaseName0"/>
<result name="oldFileName1ThatDoesNotExist" renamed="false"/>
.
.
.
</results>
Exceptions
Exception | Condition |
---|---|
[0x1] | ListNotFound: The requested list is not found. |
[0x2] | IsNotLibrary: The requested list, although found, is not a picture library. |
[0x3] | ItemNotFound: The requested list item is not found. |
[0x4] | FolderNotFound: The requested folder is not found. |
[0x5] | InvalidArgument: One or more arguments are not valid. |
[0x6] | FileExists: The file already exists, and the user does not specify the overwrite option. |
Examples
The following example renames the image file the in the "My Pictures" picture library at http://MyServer/sites/mynewsite/MyPictures/1/Red Figure2.gif.
Note
This code assumes that the site and the picture library already exist and that you have permissions on the server. xmlele is a static variable that contains the XML request for renaming items.
Dim imgws As New Web_Reference.Imaging()
imgws.Credentials = System.Net.CredentialCache.DefaultCredentials
imgws.Url = "http://MyServer/sites/mynewsite/_vti_bin/imaging.asmx"
Dim resdoc As New System.Xml.XmlDocument()
Dim resnode As System.Xml.XmlNode =
resdoc.CreateNode(System.Xml.XmlNodeType.Element, "Result", "")
resnode = imgws.Rename("My Pictures", "1", xmlele)
MessageBox.Show(resnode.ChildNodes(0).InnerText)
Web_Reference.Imaging imgws = new Web_Reference.Imaging();
imgws.Credentials = System.Net.CredentialCache.DefaultCredentials;
imgws.Url = "http://MyServer/sites/mynewsite/_vti_bin/imaging.asmx";
System.Xml.XmlDocument resdoc= new System.Xml.XmlDocument();
System.Xml.XmlNode resnode =
resdoc.CreateNode(System.Xml.XmlNodeType.Element,"Result","");
resnode = imgws.Rename("My Pictures","1",xmlele);
MessageBox.Show(resnode.ChildNodes[0].InnerText);