共用方式為


Dws.DeleteFolder Method

Deletes a subfolder from a document library of the current Document Workspace site.

Namespace:  [DWS Web service]
Web service reference: http://Site/_vti_bin/DWS.asmx

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/dws/DeleteFolder", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/dws/",  _
    ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/dws/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function DeleteFolder ( _
    url As String _
) As String
'Usage
Dim instance As Dws
Dim url As String
Dim returnValue As String

returnValue = instance.DeleteFolder(url)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/dws/DeleteFolder", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/dws/", 
    ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/dws/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public string DeleteFolder(
    string url
)

Parameters

  • url
    Type: System.String

    String. The site-based URL of the folder to delete; for example, "Shared Documents/folder_name."

Return Value

Type: System.String
A string that returns an empty <Result/> tag when successful.

Exceptions

Exception Condition
[DWSError.NoAccess(3)]

The user does not have sufficient rights.

[DWSError.FolderNotFound(10)]

The parent folder does not exist.

Remarks

The DeleteFolder method deletes a subfolder and its contents from a document library of the current Document Workspace site without warning.

Examples

The following code example shows the use of the DeleteFolder method to delete a subfolder from the document library of the current site. The absolute URL of the folder to delete is https://server_name/sites/user_name/workspace_name/Shared Documents/folder_name. For more information about the full text of the helper functions used in this example, see the CanCreateDwsUrl method.

Try
    Dim strResult As String
    strResult = 
        dwsWebService.DeleteFolder("Shared Documents/folder_name")
    If IsDwsErrorResult(strResult) Then
        Dim intErrorID As Integer
        Dim strErrorMsg As String
        Call ParseDwsErrorResult(strResult, intErrorID, strErrorMsg)
        MessageBox.Show _
            ("A document workspace error occurred." & vbCrLf & _
            "Error number: " & intErrorID.ToString & vbCrLf & _
            "Error description:" & strErrorMsg, _
            "DWS Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Else
        MessageBox.Show("The folder was successfully deleted.", _
            "Delete Folder", MessageBoxButtons.OK, _
            MessageBoxIcon.Information)
    End If
Catch exc As Exception
    MessageBox.Show("An exception occurred." & vbCrLf & _
        "Description: " & exc.Message, _
        "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
try
{
    string strResult = "";
    strResult = 
        dwsWebService.DeleteFolder("Shared Documents/folder_name");
    if (IsDwsErrorResult(strResult))
    {
        int intErrorID  = 0;
        string strErrorMsg = "";
        ParseDwsErrorResult(strResult, out intErrorID, 
            out strErrorMsg);
        MessageBox.Show
            ("A document workspace error occurred.\r\n" +
            "Error number: " + intErrorID.ToString() + "\r\n" +
            "Error description: " + strErrorMsg,
            "DWS Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    else
    {
        MessageBox.Show
            ("The folder was successfully deleted.",
            "Delete Folder", MessageBoxButtons.OK,
            MessageBoxIcon.Information);
    }
}
catch (Exception exc)
{
    MessageBox.Show("An exception occurred.\r\n" +
        "Description: " + exc.Message,
        "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

See Also

Reference

Dws Class

Dws Members

DWS Web Service