MOVE and COPY Sample Code

                 

 
Special Edition Using Microsoft SharePoint Portal Server
By Robert  Ferguson

Table of Contents
Chapter  16.   Using WebDAV Protocol to Create Web Parts


In this sample, we will introduce two more settings in the request header, Destination and Overwrite. We need the destination and source to be able to copy or move resources.

We also need to define what should be done if we have a resource with the same name . The default action will be overwrite, and we can change the default by indicating "F" for the overwrite value.

Listing 16.9 shows the sample code for copying the SPSLOCK.doc document from the /documents/marketing/ folder to /portal Content/resources/:

Listing 16.9 The Sample VBScript Code for the COPY Method of WebDAV Protocol
 Dim strServer Dim strWorkspace Dim strFolder Dim strURL Dim strUser Dim strPassword Dim DAVRequest strServer = "dianatr" strWorkspace = "spsbook" strUser = "dianatr0\spsuser" strPassword = "spspw" strURL = "http://" + strServer + "/" + strWorkspace + "/DOCUMENTS/MARKETING/SPSLOCK.doc" strURL = Replace(strURL, " ", "%20") strURLDest = "http://" + strServer + "/" + strWorkspace + "/portal content/resources/ graphics/ccc.gif SPSLOCK.doc " strURLDest = Replace(strURLDest, " ", "%20") Set DAVRequest = CreateObject("MSXML2.xmlhttp") DAVRequest.open "COPY", strURL, False, strUser, strPassword DAVRequest.setRequestHeader "Content-Type", "text/xml" DAVRequest.setRequestHeader "Destination:", StrURLDest DAVRequest.setRequestHeader "Overwrite", "T" DAVRequest.send 

The MOVE method provides a combination of deleting the source resources and copying the resource to a destination, and returns status code 201, which means the collection was successfully created or the resource was successfully moved.


                 
Top


Special Edition Using Microsoft SharePoint Portal Server
Special Edition Using Microsoft SharePoint Portal Server
ISBN: 0789725703
EAN: 2147483647
Year: 2002
Pages: 286

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net