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. Not able to write .doc file in Win32 using FILE pointer.

Not able to write .doc file in Win32 using FILE pointer.

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminhelpquestion
9 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
    vijay_k
    wrote on last edited by
    #1

    Hello, I have made client server communication and I am sending and recieving Files. I am using file pointer and fread and fwrire commands to read and write file. I am able to read and write .txt,.GIF files.but I could not write .doc file. I am opening file in binary mode only. I am reciveing file with same size as I sent. but after opening .doc file I got an error that "word was unable to read the file". can any one tell me what might be the reason behind that? do I need any special code to read and write .doc file? Thank You... vijay.

    CPalliniC R 2 Replies Last reply
    0
    • V vijay_k

      Hello, I have made client server communication and I am sending and recieving Files. I am using file pointer and fread and fwrire commands to read and write file. I am able to read and write .txt,.GIF files.but I could not write .doc file. I am opening file in binary mode only. I am reciveing file with same size as I sent. but after opening .doc file I got an error that "word was unable to read the file". can any one tell me what might be the reason behind that? do I need any special code to read and write .doc file? Thank You... vijay.

      R Offline
      R Offline
      Rajkumar R
      wrote on last edited by
      #2

      have you tried with file compare tools like windiff.

      1 Reply Last reply
      0
      • V vijay_k

        Hello, I have made client server communication and I am sending and recieving Files. I am using file pointer and fread and fwrire commands to read and write file. I am able to read and write .txt,.GIF files.but I could not write .doc file. I am opening file in binary mode only. I am reciveing file with same size as I sent. but after opening .doc file I got an error that "word was unable to read the file". can any one tell me what might be the reason behind that? do I need any special code to read and write .doc file? Thank You... vijay.

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        vijay_k wrote:

        can any one tell me what might be the reason behind that?

        Only CP members with superpowers and the CPMRU (Code Project Mind Reader Unit) turned ON.

        vijay_k wrote:

        do I need any special code to read and write .doc file?

        No. But you have to make sure that the transferred file is identical to the original one. You may use a tool such a Windiff to verify it. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

        In testa che avete, signor di Ceprano?

        V 1 Reply Last reply
        0
        • CPalliniC CPallini

          vijay_k wrote:

          can any one tell me what might be the reason behind that?

          Only CP members with superpowers and the CPMRU (Code Project Mind Reader Unit) turned ON.

          vijay_k wrote:

          do I need any special code to read and write .doc file?

          No. But you have to make sure that the transferred file is identical to the original one. You may use a tool such a Windiff to verify it. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

          V Offline
          V Offline
          vijay_k
          wrote on last edited by
          #4

          I tested it with windiff. I am getting message that created file is more recent. I am not getting what can be done next? Here I am giving You code for writing that file. if( nFile != NULL ) { numwritten = fwrite( recvbuf, sizeof(char),length, nFile ); fclose(nFile) } else MessageBox(NULL,"Problem opening file",NULL,NULL); Do I need to use feof or any other commands? Thank You... Vijay.

          CPalliniC 1 Reply Last reply
          0
          • V vijay_k

            I tested it with windiff. I am getting message that created file is more recent. I am not getting what can be done next? Here I am giving You code for writing that file. if( nFile != NULL ) { numwritten = fwrite( recvbuf, sizeof(char),length, nFile ); fclose(nFile) } else MessageBox(NULL,"Problem opening file",NULL,NULL); Do I need to use feof or any other commands? Thank You... Vijay.

            CPalliniC Offline
            CPalliniC Offline
            CPallini
            wrote on last edited by
            #5

            vijay_k wrote:

            I am getting message that created file is more recent.

            That's ok. Now, what about the differences? Can you see any difference (using Windiff, select the first item and then click the expand button)? :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

            In testa che avete, signor di Ceprano?

            V 1 Reply Last reply
            0
            • CPalliniC CPallini

              vijay_k wrote:

              I am getting message that created file is more recent.

              That's ok. Now, what about the differences? Can you see any difference (using Windiff, select the first item and then click the expand button)? :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

              V Offline
              V Offline
              vijay_k
              wrote on last edited by
              #6

              I expanded it and I got some Encrypted language contents. but on clicking on edit right file and left file I got .txt file version of both files. There is a differeence in both files.The half of the file is same and I am getting "ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ" charachters for rest of file(in created file). I am not getting why there is such difference. Thank You.... Vijay.

              CPalliniC 1 Reply Last reply
              0
              • V vijay_k

                I expanded it and I got some Encrypted language contents. but on clicking on edit right file and left file I got .txt file version of both files. There is a differeence in both files.The half of the file is same and I am getting "ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ" charachters for rest of file(in created file). I am not getting why there is such difference. Thank You.... Vijay.

                CPalliniC Offline
                CPalliniC Offline
                CPallini
                wrote on last edited by
                #7

                Probably the buffer you're writing to the output file does not contain the whole info. I think you have to check how many bytes are actually transferred between the client and the server. :)

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                In testa che avete, signor di Ceprano?

                V 1 Reply Last reply
                0
                • CPalliniC CPallini

                  Probably the buffer you're writing to the output file does not contain the whole info. I think you have to check how many bytes are actually transferred between the client and the server. :)

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                  V Offline
                  V Offline
                  vijay_k
                  wrote on last edited by
                  #8

                  Before I sent contents of file I am sending the length or size of file. And I am recieving lenght of file. I am using that length in recv() function. It is working fine for .gif file. Thank You... Vijay.

                  CPalliniC 1 Reply Last reply
                  0
                  • V vijay_k

                    Before I sent contents of file I am sending the length or size of file. And I am recieving lenght of file. I am using that length in recv() function. It is working fine for .gif file. Thank You... Vijay.

                    CPalliniC Offline
                    CPalliniC Offline
                    CPallini
                    wrote on last edited by
                    #9

                    You may check the received buffer content with the debugger. :)

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                    In testa che avete, signor di Ceprano?

                    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