| View previous topic :: View next topic |
| Author |
Message |
rhartl Member
Joined: 12 Jun 2006 Posts: 7
|
Posted: 26/09/06 18:41 Post subject: Streams... |
|
|
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 |
|
 |
Johnny_Bit Moderator
Joined: 15 Jun 2003 Posts: 274
|
Posted: 26/09/06 20:09 Post subject: |
|
|
| 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 |
|
 |
rhartl Member
Joined: 12 Jun 2006 Posts: 7
|
Posted: 26/09/06 20:39 Post subject: Sorry... |
|
|
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 |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
Posted: 26/09/06 21:06 Post subject: |
|
|
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 |
|
 |
|