How do I check if a ftp directory is empty?

Hello
I am writing an application to connect to a ftp server, and read the ftp files in a a ftp directory. How do I check if the ftp directory is empty or not? Any suggestions will be appreciate
JeeckAsked:
Who is Participating?
 
AmickCommented:
Here's a discussion that you may find useful: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/12e8de79-c544-4164-8c4e-0ba75fb9096f

Meanwhile, the fact that the statement is failing when there are no files allows you to use error handling to accomodate that situation, right?

Also you might consider using FtpWebResponse. Any data returned by the request, such as the list of file names returned for a ListDirectory request, is available in the stream returned by the GetResponseStream method. The length of the stream data can be obtained from the ContentLength property.  I believe a length of zero would tell you what you need to know.

0
 
AmickCommented:
One way would be to examine the return from the ls command.
0
 
JeeckAuthor Commented:
This is what I am doing
Dim strFileName  as string() = Strings.Split(newFTP.ListDirectory("/MyDirectory/")(0), vblf)I
This code works fine if I have files in the directory. But, of Course, if there are no files in the directory, it doesn't work anymore. I am thinking about checking  newFTP.ListDirectory("/MyDirectory/") first, but don't know. I am trying all combinations but not succes yet.
If newFTP.ListDirectoryDetail("/ClientUpdateLog/") Is Nothing Then

              '  Do nothing
 End If
Can you be specific about the Is command?
0
 
JeeckAuthor Commented:
Just have to copy and paste. :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.