Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
15.2k views
in .NET FTP by
Hi there. What methods/properties would I use in the FTPClient to recursively loop through a folder and delete all files/subfolders in it.

It looks like Dir or DirDetails might be something like what I'm looking for. Basically, I just need a method that will list the subdirectories, and a method that will list the files.


WATYF

16 Answers

0 votes
by (162k points)
Hi, we hope to get a resolution very soon

Did you guys find anything out about this issue? Do you need any more test runs from me? Please let me know. I've found that I can't really use this component unless I get the DirDetails issue fixed, since it doesn't provide an accurate list of files/folders on an FTP server.


WATYF
0 votes
by (162k points)
We think we've figured out the problem - sorry for the late reply.

Take a look at this thread.

http://www.enterprisedt.com/forums/view ... =2206#2206

Is this the same problem?

Did you guys find anything out about this issue? Do you need any more test runs from me? Please let me know. I've found that I can't really use this component unless I get the DirDetails issue fixed, since it doesn't provide an accurate list of files/folders on an FTP server.


WATYF
0 votes
by (180 points)
It sounds like it might be the same problem, but what is the solution? You mentioned cd'ing into the directory and using dir, but dir returns files and folders... I need a way to distinguish between files and folders (if I didn't, I wouldn't be using DirDetails in the first place).

I would use ftp.Dir(True) and parse the responce myself, but that method appears to have th same flaw as DirDetails.


WATYF
0 votes
by (162k points)
Use DirDetails("") or DirDetails(".") to get the listing of the current directory. That should work - you will then know what are dirs and files for the current dir.

It seems that for some servers DirDetails("dirname") doesn't work when you are in the parent dir of dirname.

It sounds like it might be the same problem, but what is the solution? You mentioned cd'ing into the directory and using dir, but dir returns files and folders... I need a way to distinguish between files and folders (if I didn't, I wouldn't be using DirDetails in the first place).

I would use ftp.Dir(True) and parse the responce myself, but that method appears to have th same flaw as DirDetails.


WATYF
0 votes
by (180 points)
Hrmm... that complicates things. :(

Is this something that will be fixed in a later version, or is this an unavoidable flaw in some servers? I only ask because the methods I'm using to recursively delete/browse ftp folders are built into a much larger class that relies entirely on passing full paths (whether locally or remote). So if I can't find some kind of workaround, it would take a good bit of re-design just to get this one quirk fixed.

If it's not something that will be fixed in the future, then maybe you can give me a tip on a workaround.... I'm trying to figure out how to return to the parent directory of a user. That way, after I'm done recursively looping through all the folders, I can just go back to the root parent directory before continuing with the rest of the functions (which rely on being in the root directory). I tried CdUp, but that doesn't return a value, so I can't tell once I've reached the root directory. I have some ideas on how I might be able to handle this, but I just wanted to check and see if there was a direct way of doing it before I continued.


WATYF
0 votes
by (162k points)
With some servers this seems to be unavoidable.

A workaround which we've implemented in our recursive code (in edtFTPnet/PRO) is to use a recursive method - at the beginning of the method it cds into the directory and at the end it cdups out of it. The recursion automatically keeps track of where you are.


Hrmm... that complicates things. :(

Is this something that will be fixed in a later version, or is this an unavoidable flaw in some servers? I only ask because the methods I'm using to recursively delete/browse ftp folders are built into a much larger class that relies entirely on passing full paths (whether locally or remote). So if I can't find some kind of workaround, it would take a good bit of re-design just to get this one quirk fixed.

If it's not something that will be fixed in the future, then maybe you can give me a tip on a workaround.... I'm trying to figure out how to return to the parent directory of a user. That way, after I'm done recursively looping through all the folders, I can just go back to the root parent directory before continuing with the rest of the functions (which rely on being in the root directory). I tried CdUp, but that doesn't return a value, so I can't tell once I've reached the root directory. I have some ideas on how I might be able to handle this, but I just wanted to check and see if there was a direct way of doing it before I continued.


WATYF

Categories

...