I've been working on an FTP program for some time now and have run into a small block. The program needs to pull a directory listing off a UNIX server and store it on a local file. I need a complete listing that includes date/time. I have been using function calls to the wininet.dll file for my ftp connections and transfers. However, there is no direct function for the FTP dir command. I believe I need to use the FtpCommand function. Microsoft describes this function as "Allows an application to send commands directly to an FTP server." The syntax is:

BOOL FtpCommand( HINTERNET hConnect,
BOOL fExpectResponse,
DWORD dwFlags,
LPCSTR lpszCommand,
DWORD_PTR dwContext,
HINTERNET* phFtpCommand);

You can find MS info on it <a href="http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/wininet/reference/functions/ftpcommand.asp">here.</a>

I am able to connect to the FTP server and have been using my current code to transfer files and perform other common tasks. The problem is just with getting a directory from the server. My code so far looks like this:

Dim bRet As Boolean
Dim strCommand As String
Connect 'runs connection routine
strCommand = "dir " & strRemotePath & " " & strUNIXDirectory
bRet = FtpCommand(hConnection, False, FTP_TRANSFER_TYPE_BINARY, _
strCommand, 0, hConnection)

The strRemotePath and strUNIXDirectory are module variables that store the server's remote path and the local file for the UNIX directory respectively. Both of these variables are defined properly. The proper declare function was placed in a module specifically holding all wininet.dll variables and definitions. The FtpCommand is defined there as follows:

Public Const FTP_TRANSFER_TYPE_BINARY = &H1
Public Declare Function FtpCommand Lib "wininet.dll" Alias "FtpCommandA" _
(ByVal hFtpSession As Long, ByVal bExpectResponse As Boolean, ByVal dwFlags As Long, _
ByVal lpszCommand As String, ByVal dwContext As Long, _
ByVal hNewFtpSession As Long) As Boolean

When the program is executed, no error messages appear, but neither does the directory listing requested. Any help with this dilema will be greatly appreciated.

Thanks