DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   Watched TopicsWatched Topics     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Streams...

 
Post new topic   Reply to topic   printer-friendly view    DELPHI AREA Forum Index -> Delphi Programming
View previous topic :: View next topic  
Author Message
rhartl
Member


Joined: 12 Jun 2006
Posts: 7

PostPosted: 26/09/06 18:41    Post subject: Streams... Reply with quote

Can someone help me figure out what I am doing wrong. I am trying to write the contents of an object to a file using TFilestream. The following code writes without blowing up, but when reading the object back in I get a list that is not correct, it has an extra string at the top with a nonsense character.

writing...

Try
AFile := TFileStream.Create(FileName,fmCreate);
Except
MessageDlg('Blew up',mtError,[mbOk],0);
Exit;
End;

FKeyWords.SavetoStream(AFile);

AFile.Free;


reading...

Try
AFile := TFileStream.Create(FileName,fmOpenRead);
Except
MessageDlg('Blew up',mtError,[mbOk],0);
Exit;
End;

FKeyWords.LoadFromStream(AFile);

AFile.Free;

-- Rich
Back to top
View user's profile Send private message
Johnny_Bit
Moderator


Joined: 15 Jun 2003
Posts: 274

PostPosted: 26/09/06 20:09    Post subject: Reply with quote

Details man, details! we need details! So help us help you and give us as much data as possibe, qg. contents of file, contents of object, contents of this, contents of that, what is what, types of data and so on. You feelin' me?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
rhartl
Member


Joined: 12 Jun 2006
Posts: 7

PostPosted: 26/09/06 20:39    Post subject: Sorry... Reply with quote

FKeyWords is a TStingList type. It initially contains single random words read from a text file. I then try to write using TFilestream the contents of FKeyWords and read them back out again. FKeywords is part of another object that wraps several lists together. Is that enough?

-- Rich
Back to top
View user's profile Send private message
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1044
Location: Tehran, Iran

PostPosted: 26/09/06 21:06    Post subject: Reply with quote

According to the information you have provided, your code should work.

Maybe if you can provide a complete code, we can figure out the problem.

_________________
Kambiz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    DELPHI AREA Forum Index -> Delphi Programming All times are GMT
Page 1 of 1

Add to favorites

 
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
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group