Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. InternetFindNextFile???

InternetFindNextFile???

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminhelptutorialquestion
13 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ _AnsHUMAN_

    Hi All, I am working on an application that allows the user to upload files on a FTP Server. Now when I use the code below to iterate through the files on the server I just get a '.' and nothing else.

    BOOL bResult=true;
    WIN32_FIND_DATA w32fdFtpFile;
    HINTERNET hInetFindFile=::FtpFindFirstFile(hInetConn,"*.*",&w32fdFtpFile,0,0);
    if(hInetFindFile !=(HINTERNET)NULL)
    {
    	while(bResult)
    	{
            // Do something with the found file
    	bResult=::InternetFindNextFile(hInetFindFile ,&w32fdFtpFile);
    	}
    }
    InternetCloseHandle (hInetFindFile);
    

    Can someone point out what I am doing wrong here. Thanks for any help. Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

    D Offline
    D Offline
    David Crow
    wrote on last edited by
    #3

    Are there files in the folder opened by FtpFindFirstFile()? Does the while loop run indefinitely, or just once?


    "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

    "Judge not by the eye but by the heart." - Native American Proverb

    _ 1 Reply Last reply
    0
    • D David Crow

      Are there files in the folder opened by FtpFindFirstFile()? Does the while loop run indefinitely, or just once?


      "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

      "Judge not by the eye but by the heart." - Native American Proverb

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #4

      Thanks for replying David. Yes there are files on the server.It shows me only one '.' and nothing else.Any suggestions on how I get all the files. Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

      D 1 Reply Last reply
      0
      • _ _AnsHUMAN_

        Thanks for replying David. Yes there are files on the server.It shows me only one '.' and nothing else.Any suggestions on how I get all the files. Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #5

        _AnShUmAn_ wrote:

        Yes there are files on the server.

        I did not ask if there were files on the server. I asked if there were files in a specific folder. Since you specified a relative path, rather than an absolute path, to FtpFindFirstFile(), you may very well be in a folder (i.e., CWD) that has no files.


        "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

        "Judge not by the eye but by the heart." - Native American Proverb

        _ 1 Reply Last reply
        0
        • D David Crow

          _AnShUmAn_ wrote:

          Yes there are files on the server.

          I did not ask if there were files on the server. I asked if there were files in a specific folder. Since you specified a relative path, rather than an absolute path, to FtpFindFirstFile(), you may very well be in a folder (i.e., CWD) that has no files.


          "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

          "Judge not by the eye but by the heart." - Native American Proverb

          _ Offline
          _ Offline
          _AnsHUMAN_
          wrote on last edited by
          #6

          Hi David, Can you put some light on how can I set the path of the folder on the FTP Server whose files I want to display in my application Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

          D 1 Reply Last reply
          0
          • _ _AnsHUMAN_

            Hi David, Can you put some light on how can I set the path of the folder on the FTP Server whose files I want to display in my application Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #7

            Check out FtpSetCurrentDirectory() and FtpGetCurrentDirectory().


            "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

            "Judge not by the eye but by the heart." - Native American Proverb

            _ 1 Reply Last reply
            0
            • D David Crow

              Check out FtpSetCurrentDirectory() and FtpGetCurrentDirectory().


              "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

              "Judge not by the eye but by the heart." - Native American Proverb

              _ Offline
              _ Offline
              _AnsHUMAN_
              wrote on last edited by
              #8

              Thanks again David. I managed to get that working earlier. Can you provide me a link on how could I set up a callback function for InternetStatusCallback. At present I am doing this way

              hInetOpen = InternetOpen("MyFTPClient",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,INTERNET_FLAG_ASYNC);
              	INTERNET_STATUS_CALLBACK inetStatusCallback  =InternetSetStatusCallback(hInetOpen ,(INTERNET_STATUS_CALLBACK)InternetStatusCallback );
              	if(inetStatusCallback  == INTERNET_INVALID_STATUS_CALLBACK)
              	{
              		CString szErrMsg;
              		szErrMsg.Format("%s: %d", "InternetData : InternetSetStatusCallback: ",GetLastError());
              		return false;
              	}
              

              I am getting an error "type cast' : cannot convert from 'overloaded-function' to 'INTERNET_STATUS_CALLBACK' " Thanks. Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_ -- modified at 8:46 Friday 21st July, 2006

              D 1 Reply Last reply
              0
              • _ _AnsHUMAN_

                Thanks again David. I managed to get that working earlier. Can you provide me a link on how could I set up a callback function for InternetStatusCallback. At present I am doing this way

                hInetOpen = InternetOpen("MyFTPClient",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,INTERNET_FLAG_ASYNC);
                	INTERNET_STATUS_CALLBACK inetStatusCallback  =InternetSetStatusCallback(hInetOpen ,(INTERNET_STATUS_CALLBACK)InternetStatusCallback );
                	if(inetStatusCallback  == INTERNET_INVALID_STATUS_CALLBACK)
                	{
                		CString szErrMsg;
                		szErrMsg.Format("%s: %d", "InternetData : InternetSetStatusCallback: ",GetLastError());
                		return false;
                	}
                

                I am getting an error "type cast' : cannot convert from 'overloaded-function' to 'INTERNET_STATUS_CALLBACK' " Thanks. Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_ -- modified at 8:46 Friday 21st July, 2006

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #9

                _AnShUmAn_ wrote:

                I am getting an error "type cast' : cannot convert from 'overloaded-function' to 'INTERNET_STATUS_CALLBACK' "

                You failed to indicate the offending statement. How is InternetStatusCallback() defined?

                _AnShUmAn_ wrote:

                szErrMsg.Format("%s: %d", "InternetData : InternetSetStatusCallback: ",GetLastError());

                GetLastError() returns a DWORD, not an int.


                "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                "Judge not by the eye but by the heart." - Native American Proverb

                _ 1 Reply Last reply
                0
                • D David Crow

                  _AnShUmAn_ wrote:

                  I am getting an error "type cast' : cannot convert from 'overloaded-function' to 'INTERNET_STATUS_CALLBACK' "

                  You failed to indicate the offending statement. How is InternetStatusCallback() defined?

                  _AnShUmAn_ wrote:

                  szErrMsg.Format("%s: %d", "InternetData : InternetSetStatusCallback: ",GetLastError());

                  GetLastError() returns a DWORD, not an int.


                  "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                  "Judge not by the eye but by the heart." - Native American Proverb

                  _ Offline
                  _ Offline
                  _AnsHUMAN_
                  wrote on last edited by
                  #10

                  I post the code here[^] Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

                  D 1 Reply Last reply
                  0
                  • _ _AnsHUMAN_

                    I post the code here[^] Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #11

                    So which statement is the compiler complaining about?


                    "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                    "Judge not by the eye but by the heart." - Native American Proverb

                    _ 1 Reply Last reply
                    0
                    • D David Crow

                      So which statement is the compiler complaining about?


                      "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                      "Judge not by the eye but by the heart." - Native American Proverb

                      _ Offline
                      _ Offline
                      _AnsHUMAN_
                      wrote on last edited by
                      #12

                      Everything compiles fine. Just the callback function isn't called.

                      Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

                      D 1 Reply Last reply
                      0
                      • _ _AnsHUMAN_

                        Everything compiles fine. Just the callback function isn't called.

                        Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #13

                        _AnShUmAn_ wrote:

                        Just the callback function isn't called.

                        What code do you have in place that *should* be calling it?


                        "Money talks. When my money starts to talk, I get a bill to shut it up." - Frank

                        "Judge not by the eye but by the heart." - Native American Proverb

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups