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. what is the standard way to give file name in FtpOpenFile() [modified]

what is the standard way to give file name in FtpOpenFile() [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
windows-adminhelpquestion
16 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.
  • V Offline
    V Offline
    vptech19
    wrote on last edited by
    #1

    i need to get a file from windows XP machine to my XP desktop, in both machines IIS services running. I have no error in InternetConnect(), InternetOpen(). But FtpOpenFile() fails and returns "file unavailable error". Following is the code i did in FtpOpenFile, FtpOpenFile(hConnect, TEXT("C:/good.txt"), GENERIC_READ, FTP_TRANSFER_TYPE_BINARY, NULL); Anybody have any idea to overcome this. Somebody respond ASAP please.

    modified on Thursday, February 07, 2008 7:47:52 AM

    D 1 Reply Last reply
    0
    • V vptech19

      i need to get a file from windows XP machine to my XP desktop, in both machines IIS services running. I have no error in InternetConnect(), InternetOpen(). But FtpOpenFile() fails and returns "file unavailable error". Following is the code i did in FtpOpenFile, FtpOpenFile(hConnect, TEXT("C:/good.txt"), GENERIC_READ, FTP_TRANSFER_TYPE_BINARY, NULL); Anybody have any idea to overcome this. Somebody respond ASAP please.

      modified on Thursday, February 07, 2008 7:47:52 AM

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

      vptech19 wrote:

      FtpOpenFile(hConnect, TEXT("C:/good.txt"), GENERIC_READ, FTP_TRANSFER_TYPE_BINARY, NULL);

      Does the file exist? Have you tried a (double) backslash instead?

      "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      V 1 Reply Last reply
      0
      • D David Crow

        vptech19 wrote:

        FtpOpenFile(hConnect, TEXT("C:/good.txt"), GENERIC_READ, FTP_TRANSFER_TYPE_BINARY, NULL);

        Does the file exist? Have you tried a (double) backslash instead?

        "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        V Offline
        V Offline
        vptech19
        wrote on last edited by
        #3

        [Message Deleted]

        D 1 Reply Last reply
        0
        • V vptech19

          [Message Deleted]

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

          So now you have something akin to:

          if (FtpOpenFile(hConnect, TEXT("C:\\good.txt"), GENERIC_READ, FTP_TRANSFER_TYPE_BINARY, NULL) == NULL)
          DWORD dwError = GetLastError();

          "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          V 1 Reply Last reply
          0
          • D David Crow

            So now you have something akin to:

            if (FtpOpenFile(hConnect, TEXT("C:\\good.txt"), GENERIC_READ, FTP_TRANSFER_TYPE_BINARY, NULL) == NULL)
            DWORD dwError = GetLastError();

            "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            V Offline
            V Offline
            vptech19
            wrote on last edited by
            #5

            this is also didn't work out.:confused:

            D 1 Reply Last reply
            0
            • V vptech19

              this is also didn't work out.:confused:

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

              What does GetLastError() return?

              "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              V 1 Reply Last reply
              0
              • D David Crow

                What does GetLastError() return?

                "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                V Offline
                V Offline
                vptech19
                wrote on last edited by
                #7

                it returns 12003. Please note that the user name i am logging have all the rights.

                modified on Thursday, February 07, 2008 10:47:15 AM

                D 1 Reply Last reply
                0
                • V vptech19

                  it returns 12003. Please note that the user name i am logging have all the rights.

                  modified on Thursday, February 07, 2008 10:47:15 AM

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

                  Which equates to ERROR_INTERNET_EXTENDED_ERROR. Did you then call InternetGetLastResponseInfo() to get the error text?

                  "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  V 1 Reply Last reply
                  0
                  • D David Crow

                    Which equates to ERROR_INTERNET_EXTENDED_ERROR. Did you then call InternetGetLastResponseInfo() to get the error text?

                    "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    V Offline
                    V Offline
                    vptech19
                    wrote on last edited by
                    #9

                    Tried as InternetGetLastResponseInfo(lpdwError, lpszBuffer, lpdwBufferLength); cout<<lpszBuffer; if this is correct, it have 00394BD8.

                    D 1 Reply Last reply
                    0
                    • V vptech19

                      Tried as InternetGetLastResponseInfo(lpdwError, lpszBuffer, lpdwBufferLength); cout<<lpszBuffer; if this is correct, it have 00394BD8.

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

                      vptech19 wrote:

                      cout<<lpszBuffer;

                      cout << (LPCTSTR) lpszBuffer;

                      "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                      V 1 Reply Last reply
                      0
                      • D David Crow

                        vptech19 wrote:

                        cout<<lpszBuffer;

                        cout << (LPCTSTR) lpszBuffer;

                        "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                        V Offline
                        V Offline
                        vptech19
                        wrote on last edited by
                        #11

                        it is didn't work. if i use InternetGetLastResponseInfo() & ran the program means, it breaks the code. But FtpOpenFile() returns the error code as 6 now. where can i refer the error codes?

                        D M 2 Replies Last reply
                        0
                        • V vptech19

                          it is didn't work. if i use InternetGetLastResponseInfo() & ran the program means, it breaks the code. But FtpOpenFile() returns the error code as 6 now. where can i refer the error codes?

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

                          vptech19 wrote:

                          it is didn't work. if i use InternetGetLastResponseInfo() & ran the program means, it breaks the code.

                          So you have something like:

                          if (FtpOpenFile(hConnect, TEXT("C:\\good.txt"), GENERIC_READ, FTP_TRANSFER_TYPE_BINARY, NULL) == NULL)
                          {
                          DWORD dwError = GetLastError();
                          if (ERROR_INTERNET_EXTENDED_ERROR == dwError)
                          {
                          TCHAR szErrorText[256];
                          DWORD dwSize = sizeof(szErrorText);
                          InternetGetLastResponseInfo(&dwError, szErrorText, &dwSize);
                          }
                          }

                          vptech19 wrote:

                          But FtpOpenFile() returns the error code as 6 now.

                          FtpOpenFile() returns a handle to indicate success, and NULL to indicate failure. Since 6 is not NULL, I can only assume that FtpOpenFile() is not failing.

                          "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                          1 Reply Last reply
                          0
                          • V vptech19

                            it is didn't work. if i use InternetGetLastResponseInfo() & ran the program means, it breaks the code. But FtpOpenFile() returns the error code as 6 now. where can i refer the error codes?

                            M Offline
                            M Offline
                            Mark Salsbery
                            wrote on last edited by
                            #13

                            vptech19 wrote:

                            where can i refer the error codes?

                            System Error Codes[^]

                            Mark Salsbery Microsoft MVP - Visual C++ :java:

                            V 1 Reply Last reply
                            0
                            • M Mark Salsbery

                              vptech19 wrote:

                              where can i refer the error codes?

                              System Error Codes[^]

                              Mark Salsbery Microsoft MVP - Visual C++ :java:

                              V Offline
                              V Offline
                              vptech19
                              wrote on last edited by
                              #14

                              I missed out some FTP configurations in Destination m/c, so now the FtpOpenFile() works fine. The FtpGetFile() throws 12110(ERROR_FTP_TRANSFER_IN_PROGRESS) error. Do i need to include some kind of delay after FtpOpenFile()?. To debug this i tried to login thro FTP to the source m/c(other m/c) - it is success. But i wan not able to login thro FTP to my m/c from the source m/c. I feel this may causing the problem. Do i need to set any configurations anything else mentioned in "https://engineering.purdue.edu/ECN/Support/KB/Docs/FTPSetUpWindows" and "http://articles.techrepublic.com.com/5100-6345-5031102.html".

                              M 1 Reply Last reply
                              0
                              • V vptech19

                                I missed out some FTP configurations in Destination m/c, so now the FtpOpenFile() works fine. The FtpGetFile() throws 12110(ERROR_FTP_TRANSFER_IN_PROGRESS) error. Do i need to include some kind of delay after FtpOpenFile()?. To debug this i tried to login thro FTP to the source m/c(other m/c) - it is success. But i wan not able to login thro FTP to my m/c from the source m/c. I feel this may causing the problem. Do i need to set any configurations anything else mentioned in "https://engineering.purdue.edu/ECN/Support/KB/Docs/FTPSetUpWindows" and "http://articles.techrepublic.com.com/5100-6345-5031102.html".

                                M Offline
                                M Offline
                                Mark Salsbery
                                wrote on last edited by
                                #15

                                After you've called FtpOpenFile(), the only operations you can do are InternetReadFile(), InternetWriteFile(), InternetCloseHandle(), or FtpFindFirstFile(). Once you've closed the file you can use FtpGetFile(). FtpGetFile() is meant to be used by itself - you don't need to (and can't) open the file first. You use FtpOpenFile()/InternetReadFile()/InternetCloseHandle() when you want more control over the file transfer. Mark

                                Mark Salsbery Microsoft MVP - Visual C++ :java:

                                V 1 Reply Last reply
                                0
                                • M Mark Salsbery

                                  After you've called FtpOpenFile(), the only operations you can do are InternetReadFile(), InternetWriteFile(), InternetCloseHandle(), or FtpFindFirstFile(). Once you've closed the file you can use FtpGetFile(). FtpGetFile() is meant to be used by itself - you don't need to (and can't) open the file first. You use FtpOpenFile()/InternetReadFile()/InternetCloseHandle() when you want more control over the file transfer. Mark

                                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                                  V Offline
                                  V Offline
                                  vptech19
                                  wrote on last edited by
                                  #16

                                  Yes, you are correct. Now upload and download both works fine. Thanks a lot Mark, David and all. -vp

                                  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