FTP List Results

  • Thread starter Thread starter Waldy
  • Start date Start date
W

Waldy

Hi there,
does anyone have any tips for enumerating files on an ftp
folder. I'm using the FtpWebResponse .Net object, but the output seems to
be different for each site that you connect to. Are there any built in
classes for doing this?
 
You're on the right track using FtpWebResponse. Check out this
complete sample on MSDN:

http://msdn.microsoft.com/en-us/library/ms229716(VS.80).aspx

Hi Jay,
I am aware of that example already. My question is how you do
interpret the results that are returned? My companies server reurns a
string like so:

-rw-rw-rw- 1 user group 30202473 Jun 26 14:16 AFileName.ext

The Microsoft ftp site returns a string like so:

09-28-94 04:03PM 77895 APPS.EXE
 
My question is how you do
interpret the results that are returned? My companies server reurns a
string like so:

-rw-rw-rw- 1 user group 30202473 Jun 26 14:16 AFileName.ext

The Microsoft ftp site returns a string like so:

09-28-94 04:03PM 77895 APPS.EXE

Unfortunately, the FTP standard doesn't specify the format of directory listings.
That said, I bet there are tons of free code on the web that can interpret
the most commonly encountered formats. The two mentioned above are probably
the most common; *nix and Mac OS X will use the unix-like format (the first
one), while Windows of course must be different ;-).

Sincerly,
Sune Foldager.
 
You're on the right track using FtpWebResponse.  Check out this
complete sample on MSDN:

http://msdn.microsoft.com/en-us/library/ms229716(VS.80).aspx

Hi Jay,
           I am aware of that example already.  My questionis how you do
interpret the results that are returned?  My companies server reurns a
string like so:

-rw-rw-rw-   1 user     group    30202473 Jun 26 14:16 AFileName.ext

The Microsoft ftp site returns a string like so:

09-28-94  04:03PM                77895 APPS.EXE


Hi Waldy

I guess I should have run the sample before recommending it! I see a
couple choices for you:

1. You can parse the strings returned by the sample. If they're
fixed width, this would be easy. Otherwise maybe a regex would do the
trick.

2. Like Sune mentioned, you can use existing libraries/code:
Check out this article:
http://www.codeproject.com/KB/IP/FtpClient.aspx

It mentions an FtpFileInfo object which includes a filename property.
I've never tried the code posted in the article.

There's an open source FTP component that I used a couple years ago
that will do what you need:
http://www.enterprisedt.com/products/edtftpnet/overview.html

It includes documentation and a number of samples.


-Jay
 
Back
Top