Not able to write .doc file in Win32 using FILE pointer.
-
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.
-
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.
have you tried with file compare tools like windiff.
-
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.
vijay_k wrote:
can any one tell me what might be the reason behind that?
Only
CP
members with superpowers and theCPMRU
(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 -
vijay_k wrote:
can any one tell me what might be the reason behind that?
Only
CP
members with superpowers and theCPMRU
(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 ClarkeI 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.
-
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.
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 -
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 ClarkeI 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.
-
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.
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 -
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 -
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.
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