The problems probably to do with the fact that your WebdavResource is now
pointing at a non-existent resource (i.e. newFile).
Try setting the path to point at the directory, and then re-issuing the
deleteMethod.
i.e.
webDavResource.setPath(newDirectory);
boolean directoryDeleted = webDavResource.deleteMethod();
Hope this helps.
Anthony.
> -----Original Message-----
> From: Lewis, Eric [SMTP:[EMAIL PROTECTED]
> Sent: Monday, 19 December 2005 20:50
> To: '[email protected]'
> Subject: Newbie: How to delete a directory?
>
> Hi all
>
> I'm new to Slide and thus to this mailing list.
> I'm using the WebDAV client and trying to create a directory and save a
> file
> in it. This works (except for character set problems), but when I want to
> delete them, I'm having problems.
> The file can be deleted without error, but as soon as I try to delete the
> directory, I get a HTTP response 301, and the deleteMethod() returns
> false.
>
> I'm testing with the 'official' WebDAV test server at
> http://test.webdav.org/dav/
>
> Any help would be greatly appreciated! :-)
>
>
> Here's my source:
> /**
> * The root folder for WebDAV
> */
> private static final String TEST_WEBDAV_ROOT = "/dav/";
>
> /**
> * A test WebDAV server open for client tests.
> */
> private static final String TEST_WEBDAV_HTTP_URL =
> "http://test.webdav.org"
> + TEST_WEBDAV_ROOT;
>
> /**
> * The directory that's written to the test WebDAV server
> */
> private static final String TEST_WEBDAV_DIRECTORY_TO_WRITE =
> "mmmyyy_test_directory";
>
> /**
> * The file that's written to the test WebDAV server
> */
> private static final String TEST_WEBDAV_FILE_TO_WRITE =
> "this_is_my_test_file.txt";
>
>
>
> (Create directory and file)
>
>
>
> String newDirectory = TEST_WEBDAV_ROOT + TEST_WEBDAV_DIRECTORY_TO_WRITE;
> String newFile = newDirectory + "/" + TEST_WEBDAV_FILE_TO_WRITE;
> WebdavResource webDavResource = new WebdavResource(TEST_WEBDAV_HTTP_URL);
> boolean fileDeleted = webDavResource.deleteMethod(newFile);
> if (! fileDeleted) {
> log.error("Couldn't delete file " + newFile + ": " +
> webDavResource.getStatusCode() + ", " +
> webDavResource.getStatusMessage());
> }
> boolean directoryDeleted = webDavResource.deleteMethod(newDirectory);
> if (! directoryDeleted) {
> log.error("Couldn't delete directory " + newDirectory + ": " +
> webDavResource.getStatusCode() + ", " +
> webDavResource.getStatusMessage());
> }
> webDavResource.close();
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
-----------------------------------------------------------------------------------
This e-mail is sent by Suncorp-Metway Limited ABN 66 010 831 722 or one of its
related entities "Suncorp".
Suncorp may be contacted at Level 18, 36 Wickham Terrace, Brisbane or on 13 11
55 or at suncorp.com.au.
The content of this e-mail is the view of the sender or stated author and does
not necessarily reflect the view of Suncorp. The content, including
attachments, is a confidential communication between Suncorp and the intended
recipient. If you are not the intended recipient, any use, interference with,
disclosure or copying of this e-mail, including attachments, is unauthorised
and expressly prohibited. If you have received this e-mail in error please
contact the sender immediately and delete the e-mail and any attachments from
your system.
If this e-mail constitutes a commercial message of a type that you no longer
wish to receive please reply to this e-mail by typing Unsubscribe in the
subject line.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]