BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

MIME Encoding and TFileStream error

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Socket)
View previous topic :: View next topic  
Author Message
Mr. Wuf
Guest





PostPosted: Sun Jan 29, 2006 6:40 pm    Post subject: MIME Encoding and TFileStream error Reply with quote



Hello,

why does this code not work? Error: Stream read error

TFileStream *FStream = new TFileStream("C:\somefile.xyz", fmOpenRead ||
fmShareDenyWrite);
String SndText = IdEncoderMIME1->Encode(FStream, FStream->Size);
delete FStream;

Where is the problem?


Back to top
Hans Galema
Guest





PostPosted: Sun Jan 29, 2006 8:18 pm    Post subject: Re: MIME Encoding and TFileStream error Reply with quote



Mr. Wuf wrote:

Quote:
why does this code not work? Error: Stream read error

fmOpenRead || fmShareDenyWrite

You should bitwise construct the Mode parameter:

fmOpenRead | fmShareDenyWrite

Hans.

Back to top
Mr. Wuf
Guest





PostPosted: Mon Jan 30, 2006 9:14 am    Post subject: Re: MIME Encoding and TFileStream error Reply with quote



Sorry, my next problem: I need to transfer a binary file as a string. When I
decode the base64 string to a TFileStream I get corrupted files!

TFileStream *FStream = new TFileStream("C:\test.png", fmCreate |
fmOpenReadWrite);
IdDecoderMIME1->DecodeToStream(Memo1->Text,FStream);
// FStream->Size = 130677; // original filesize: 130677, size of corrupted
file: 140768
delete FStream;


Back to top
Hans Galema
Guest





PostPosted: Mon Jan 30, 2006 10:04 am    Post subject: Re: MIME Encoding and TFileStream error Reply with quote

Mr. Wuf wrote:
Quote:
Sorry, my next problem: I need to transfer a binary file as a string. When I
decode the base64 string to a TFileStream I get corrupted files!

Seeing your code you mean: I did base64 encode the contents of a file. And
no I try to decode it to a stream.

Quote:
TFileStream *FStream = new TFileStream("C:\test.png", fmCreate |
fmOpenReadWrite);
IdDecoderMIME1->DecodeToStream(Memo1->Text,FStream);
// FStream->Size = 130677; // original filesize: 130677, size of corrupted
file: 140768
delete FStream;

Corrupted ? It is longer yes. But what do contain the first 130677 bytes ?
The original file contents ?

What is in the result file ? Dit you look in it ?

Hans.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Socket) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.