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?


Thanks,

Vmax.

I dont know sokcet programing. but I do know that word, can open txt files, so a simple way would be to open the file using .doc extention & in text format, write to the file & close it. It should work.

I guess, I mis understood. If you are reading, a word doc & saving it, then it sould work with binary mode. Perhaps, your client, doesnt have the latest version & lack upward compatibility. This may be a reson. And this is just a guess

I tried, to copy a word file within my computer(not socket program) and it worked.

Hi Prabakar,
Thank You for Your response.
I am creating .doc file.recieving bytes from client and writing that bytes to created .doc file.
If client is sending .txt file then at the server side I have written the content of that text file in .doc file succesfully.
but i am not able to create text file at the server side if client is sendig txt file contents.


Thank You..

vmax.

All I know in socket programing, is TCP/UDP echo program. so, I dont think I can help you with this.

And I dont understand, your reply too. why should you not be able to read .txt files from client. Is it because you dont know the nature of the file being transmitted by the client ?

> do I need any special code to read and write .doc file?
What system(s) are you running the program on / transferring the files between?

Perhaps word on your machine makes use of alternate data streams, and you're not in fact copying the whole file. There are hidden parts which you're not copying.
http://support.microsoft.com/kb/105763
Gotta love those vendor lock-in features :icon_rolleyes:

Did you get a solution to this issue?

commented: When more than 2 weeks have passed, it's safe to assume that you shouldn't reply to the thread. -4

I too need a code to be able to open a doc file in C++. I am a rookie and know that C++ can input plain txt files with its inbuilt functions. But I don't know is there any free library or inbuilt function to read a doc file for further parsing procedures?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.