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. open txt file form web or ftp ?

open txt file form web or ftp ?

Scheduled Pinned Locked Moved C / C++ / MFC
questionsysadminhelp
8 Posts 5 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.
  • D Offline
    D Offline
    da_
    wrote on last edited by
    #1

    Hello sry for may bad english im a Austrian Ok now my question I have a litle Prog witch opens a txt file from my local hdd, now i want to open a txt file from my web serv and put it out on te consol. But how can i open the file ? it doesn't work ptr = fopen("\\http://king.ath.cx//server.txt" ,"r+"); if(ptr == NULL) { printf("\nfopen error\n"); getchar(); Lg Alex

    L N D 4 Replies Last reply
    0
    • D da_

      Hello sry for may bad english im a Austrian Ok now my question I have a litle Prog witch opens a txt file from my local hdd, now i want to open a txt file from my web serv and put it out on te consol. But how can i open the file ? it doesn't work ptr = fopen("\\http://king.ath.cx//server.txt" ,"r+"); if(ptr == NULL) { printf("\nfopen error\n"); getchar(); Lg Alex

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You must first copy the file onto your local disk, either through your browser or via FTP.

      It's time for a new signature.

      1 Reply Last reply
      0
      • D da_

        Hello sry for may bad english im a Austrian Ok now my question I have a litle Prog witch opens a txt file from my local hdd, now i want to open a txt file from my web serv and put it out on te consol. But how can i open the file ? it doesn't work ptr = fopen("\\http://king.ath.cx//server.txt" ,"r+"); if(ptr == NULL) { printf("\nfopen error\n"); getchar(); Lg Alex

        N Offline
        N Offline
        norish
        wrote on last edited by
        #3

        I can say one of old style of coding (not a .net style, I'm saying) with WinInet. The primary usage is thus; <pre> HINTERNET hInet = InternetOpen("MyLocalAgent", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); HINTERNET hFile = InternetOpenUrl(hInet, "http://king.ath.cx/server.txt", NULL, 0, 0); BYTE buffer[BUFSIZE]; DWORD dwRead; while (InternetReadFile(hFile, buffer, BUFSIZE, &dwRead)) { if (0 == dwRead) break; fwrite(buffer, 1, dwRead, stdout); } InternetCloseHandle(hFile); InternetCloseHandle(hInet); </pre>

        1 Reply Last reply
        0
        • D da_

          Hello sry for may bad english im a Austrian Ok now my question I have a litle Prog witch opens a txt file from my local hdd, now i want to open a txt file from my web serv and put it out on te consol. But how can i open the file ? it doesn't work ptr = fopen("\\http://king.ath.cx//server.txt" ,"r+"); if(ptr == NULL) { printf("\nfopen error\n"); getchar(); Lg Alex

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

          You could either open it using a UNC path, or try using URLDownloadToFile().

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Man who follows car will be exhausted." - Confucius

          W 1 Reply Last reply
          0
          • D da_

            Hello sry for may bad english im a Austrian Ok now my question I have a litle Prog witch opens a txt file from my local hdd, now i want to open a txt file from my web serv and put it out on te consol. But how can i open the file ? it doesn't work ptr = fopen("\\http://king.ath.cx//server.txt" ,"r+"); if(ptr == NULL) { printf("\nfopen error\n"); getchar(); Lg Alex

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            You could use CInternetSession , CSdioFile, CHttpFile and CInternetFile MFC classes to read data from remote file based on HTTP and FTP protocols.

            Life is a stage and we are all actors!

            D 1 Reply Last reply
            0
            • L Lost User

              You could use CInternetSession , CSdioFile, CHttpFile and CInternetFile MFC classes to read data from remote file based on HTTP and FTP protocols.

              Life is a stage and we are all actors!

              D Offline
              D Offline
              da_
              wrote on last edited by
              #6

              But how can I do it could you help me

              L 1 Reply Last reply
              0
              • D da_

                But how can I do it could you help me

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                You may start your research from here.

                Life is a stage and we are all actors!

                1 Reply Last reply
                0
                • D David Crow

                  You could either open it using a UNC path, or try using URLDownloadToFile().

                  "One man's wage rise is another man's price increase." - Harold Wilson

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  "Man who follows car will be exhausted." - Confucius

                  W Offline
                  W Offline
                  wangningyu
                  wrote on last edited by
                  #8

                  but URLDownloadToFile() cannot down the LAN's web server ,like this : http://192.168.1.200/myfree.txt :)

                  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