CFtpConnection::Command won't compile!
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Thread: CFtpConnection::Command won't compile!

  1. #1
    Join Date
    Mar 2004
    Location
    Kennesaw, GA, USA
    Posts
    39

    CFtpConnection::Command won't compile!

    I need some help . The CFtpConnection object in the code below seems to work well if I comment out the

    "if(pFTPSite->Command..." function.

    However, when the command function is not commented out, a compilation error occurs.

    What is causing this error? The CFtpConnection object is obviously working for the other functions. I have included afxinet.h in the file. I've also installed the latest SDK and added wininet.lib to the project settings for the linker (something I saw in another thread).


    The error is,

    c:\Visual C++ Applications\UnixScriptGenerator\RunScriptWizard.cpp(929) : error C2039: 'Command' : is not a member of 'CFtpConnection'
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxinet.h(371) : see declaration of 'CFtpConnection'
    c:\Visual C++ Applications\UnixScriptGenerator\RunScriptWizard.cpp(929) : error C2065: 'CmdRespNone' : undeclared identifier



    The code is,

    void CRunScriptSTDIODialog::RetrieveInputList()
    {
    CInternetSession sess;
    CFtpConnection* pFTPSite = NULL;
    CUnixScriptGeneratorDoc* pDoc = CUnixScriptGeneratorDoc::GetDocument();
    ASSERT_VALID(pDoc);

    UpdateData(TRUE);

    try{
    pFTPSite = sess.GetFtpConnection(pDoc->pDefaultCProfile->m_strFTPServerID,
    pDoc->pDefaultCProfile->m_strUserID,pDoc->pDefaultCProfile->m_strUserPassword,
    (INTERNET_PORT)pDoc->pDefaultCProfile->m_nPortNumber);
    if(pFTPSite->SetCurrentDirectory(pDoc->newRunScript.m_strRemotePathToInputFiles)==0){
    AfxMessageBox("Could not set current directory on ftp site",MB_ICONEXCLAMATION);
    }
    if(pFTPSite->Command("ls *.inp > UnixScriptGenTemp", CmdRespNone, FTP_TRANSFER_TYPE_ASCII, 1)==0){
    AfxMessageBox("Could not perform ls command on ftp site",MB_ICONEXCLAMATION);
    }

    }
    catch (CInternetException* pEx){
    AfxGetApp()->LoadStandardCursor(IDC_ARROW);
    pEx->ReportError(MB_ICONEXCLAMATION);
    pFTPSite = NULL;
    pEx->Delete();
    }
    delete pFTPSite;
    }


    btw, I'm running on a Windows 2000 Professional box.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,353
    Hi!
    The compiler wrote you:
    'Command' : is not a member of 'CFtpConnection'
    And what do you want now?
    Are you sure your CFtpConnection class still has this method?
    I don't know which methods does CFtpConnection contain in VC7, but in VC6 there is no such method

    Regards

  3. #3
    Join Date
    Mar 2004
    Location
    Kennesaw, GA, USA
    Posts
    39
    If you check MSDN online,

    http://msdn.microsoft.com/library/de...ioncommand.asp


    you will see that they list Command as one of CFtpConnection's member functions. Additionally, as I type the line of code in, a popup list of available functions appear and Command is one of them. I even selected the function from the popup list. It appears to me that all of the documentation is in place, but the function itself was left out. I am hoping this is not the case because I need to be able to run a command in an ftp connection on a remote server.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,353
    Hmmm...
    Thanks for the link to MSDN online.
    Unfortunately, i cannot every time look at "MSDN online" and my MSDN is from october 2000.

    BTW, have you seen the "declaration of 'CFtpConnection'" in
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxinet.h(371), as your compiler had recommended you?
    Is there CFtpConnection Command method declared?

  5. #5
    Join Date
    Mar 2004
    Location
    Kennesaw, GA, USA
    Posts
    39
    Per your suggestion, I looked in afxinet.h and found the following.


    #if _WIN32_IE >= 0x0500
    CInternetFile* Command(LPCTSTR pszCommand, CmdResponseType eResponse = CmdRespNone,
    DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY,
    DWORD_PTR dwContext = 1);
    #endif


    It appears that the Command function is only available if the condition,

    _WIN32_IE >= 0x0500

    is met. What does this mean?

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,353
    According to MSDN ("Using the SDK Headers"):
    _WIN32_IE >= 0x0500 means that Minimum System Required is Internet Explorer 5.0 and later, i.e Internet Explorer 5.0 or later (or several DLL that are disributed with IE 5.0) must be installed on your computer

  7. #7
    Join Date
    Dec 2003
    Location
    St. Cugat - Catalunya
    Posts
    441
    From afxinet.h
    Code:
    #if _WIN32_IE >= 0x0500
    	CInternetFile* Command(LPCTSTR pszCommand, CmdResponseType eResponse = CmdRespNone,
    		DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY,
    		DWORD_PTR dwContext = 1);
    #endif
    It looks like you need InternetExplorer v 5.00 or later ...

    Hope it helps
    Did it help? rate it.

    The best conversation I had was over forty million years ago ... and that was with a coffee machine.

  8. #8
    Join Date
    Mar 2004
    Location
    Kennesaw, GA, USA
    Posts
    39
    Thanks. I found that info too after I made my last post. I checked and as I thought, I'm running IE 6.0 sp1. So somewhere it is not picking up the correct version of IE.

  9. #9
    Join Date
    Dec 2003
    Location
    St. Cugat - Catalunya
    Posts
    441
    _WIN32_IE is defined at afxv_w32.h ... but it seems to be defined not as your actual version (I'm running IE 6.0 and my define looks like #define _WIN32_IE 0x0560) ...

    So, good question! What is really _WIN32_IE?

    Perhaps IE version at NET installation time?
    Did it help? rate it.

    The best conversation I had was over forty million years ago ... and that was with a coffee machine.

  10. #10
    Join Date
    Mar 2004
    Location
    Kennesaw, GA, USA
    Posts
    39
    Problem solved. I think.

    I first tried redefining in the source file containing the function but that didn't work.

    #define _WIN32_IE 0x0600

    So then I looked in stdafx.h and found it was defined as 0x0400.

    I redefined it there by changing it to 0x0600 and now the compilation recognizes Command. However, it is still barking on CmdRespNone.

  11. #11
    Join Date
    Dec 2003
    Location
    St. Cugat - Catalunya
    Posts
    441
    After a little search:

    afxv_w32.h(39): #define _WIN32_IE 0x0560

    h files in C:\...\Vc7\PlatformSDK\Include\ : #define _WIN32_IE 0x0501

    all stdafx.h files : #define _WIN32_IE 0x0400



    Are we expected to manually update the definition??
    Did it help? rate it.

    The best conversation I had was over forty million years ago ... and that was with a coffee machine.

  12. #12
    Join Date
    Mar 2004
    Location
    Kennesaw, GA, USA
    Posts
    39
    I can now successfully compile. I had to supply scope resolution to get CmdResponseNone to work. See the code below. My only problem now is that the command fails in execution because the ls is getting converted to caps somehow. It's never easy!


    if(pFTPSite->Command("ls *.inp > UnixScriptGenTemp", CFtpConnection::CmdRespNone, FTP_TRANSFER_TYPE_ASCII, 1)==0){
    AfxMessageBox("Could not perform ls command on ftp site",MB_ICONEXCLAMATION);
    }


    Thanks for all the help!

  13. #13
    Join Date
    Mar 2004
    Location
    Kennesaw, GA, USA
    Posts
    39
    Well I think I have it all figured out now. Although, someone may prove me wrong. It turns out that the set of commands that are available with CFtpConnection::Command are not the same set of commands available to a user in an ftp session. This is a difference in a data ftp connection vs. a control ftp connection. The commands that are available are (at least on the ftp server I'm using),


    ftp> remotehelp
    214-The following commands are recognized (* =>'s unimplemented).
    USER PORT STOR MSAM* RNTO NLST MKD CDUP PBSZ*
    PASS PASV APPE MRSQ* ABOR SITE XMKD XCUP PROT*
    ACCT* TYPE MLFL* MRCP* DELE SYST RMD STOU SIZE
    SMNT* STRU MAIL* ALLO CWD STAT XRMD AUTH* MDTM
    REIN* MODE MSND* REST XCWD HELP PWD ADAT*
    QUIT RETR MSOM* RNFR LIST NOOP XPWD CCC*
    214 Direct comments to user@hostname.
    ftp>

    So my solution was to discard using this Command function altogether and use instead the class CFtpFileFind which has a code sample in MSDN that provided me the list of files I wanted for my program.

  14. #14
    Join Date
    Apr 2004
    Posts
    1

    Lightbulb

    Try this :
    ->Command("SITE ls")

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center