Solved

Deleting directory on remote server

Posted on 2011-09-10
2
460 Views
Last Modified: 2016-09-30
At a click of a button, I want to give the user the option of deleting a directory on a web server.  The path to this directory is always the same (home/username/http-docs/somedirectory) where a directory called "somedirectory" will be deleted.  Unfortunately a directory cannot be deleted when it has other directories & files in it and these will differ.  I already have the code to log in/out of the server. All I need is  some code to do EITHER of the following:

1. Code to delete this directory even if it is not empty.

OR...

2. List all the directories and files in a directory and ALSO their sub-directories. Everything has to be listed so I can set up a delete routine. I already have the path to the top directory.

I am using a FTP component called ipwFTP1 which can use commands listed at:
http://nsoftware.com/products/component/ftp.aspx

I am using Delphi 6.  This is URGENT so I am giving the maximum 500 points for this. Many thanks for your help.
0
Comment
Question by:rincewind666
2 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 250 total points
ID: 36516779
No need to setup a delete routine.  I dont know how to do it in Delphi but the algorithmis basically this

DeleteDirectory (DirectoryName)

   For each file in DirectoryName
        If File isDirectory then   (ipwFTP1  DirListIsDir)
            DeleteDirectory(File)  
            Remove File     (ipwFTP1  RemoveDirectory)
   Next File
   Remove DirectoryName     (ipwFTP1  RemoveDirectory)

End

mlmcc
0
 
LVL 25

Assisted Solution

by:Sinisa Vuk
Sinisa Vuk earned 250 total points
ID: 36528662

Maybe you can try send string command (not using direct command):

RMDIR -r <dir_name>
or
RMDIR -rf <dir_name>

this depends on ftp server flavor.

Sinisa V.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now