G
Guest
I want to get a list of the files in an FTP folder. I have seen the example
of MSDN using the FtpWebRequest, and it's fairly trivial to execute an NLIST
command, but the trouble is that this includes directories too. I can
specify a pattern like *.* in the uri to exclude directories, but this then
does not return files without extensions and there may be some of those.
If I use LIST instead, I can tell the directories as they get tagged with
<DIR> in the results. i.e.
02-15-07 12:21PM 488 Fred.xml
02-15-07 12:21PM 488 Gary.xml
02-15-07 12:21PM 488 James
03-16-07 10:19AM <DIR> Kathy
03-16-07 11:19AM <DIR> Louise
But I'm not sure that I can rely on the filename always starting at the same
offset from the start of the line which makes parsing the results tricky.
From a google on the web, it looks like there's no defined standard for the
response to a LIST command so I don't want to rely on the layout of this.
I could use both calls and read the directory names from the results of LIST
(whatever followed a <DIR> tag) and then remove these names from the results
of a call to NLIST, but I'm wondering if there's a simpler way.
Cheers,
Bill
of MSDN using the FtpWebRequest, and it's fairly trivial to execute an NLIST
command, but the trouble is that this includes directories too. I can
specify a pattern like *.* in the uri to exclude directories, but this then
does not return files without extensions and there may be some of those.
If I use LIST instead, I can tell the directories as they get tagged with
<DIR> in the results. i.e.
02-15-07 12:21PM 488 Fred.xml
02-15-07 12:21PM 488 Gary.xml
02-15-07 12:21PM 488 James
03-16-07 10:19AM <DIR> Kathy
03-16-07 11:19AM <DIR> Louise
But I'm not sure that I can rely on the filename always starting at the same
offset from the start of the line which makes parsing the results tricky.
From a google on the web, it looks like there's no defined standard for the
response to a LIST command so I don't want to rely on the layout of this.
I could use both calls and read the directory names from the results of LIST
(whatever followed a <DIR> tag) and then remove these names from the results
of a call to NLIST, but I'm wondering if there's a simpler way.
Cheers,
Bill