Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Problem by using TFileStream: Save and Read ShortString in Delphi2010

Avatar of wantime
wantime asked on
Delphi
14 Comments1 Solution502 ViewsLast Modified:
hello all,

i have tried to save 'ABCDEFGHIJ' as ShortString in a file, when i read it from the file , i get
'ABCDEFGHIJ\ö'. It seems there are more sysbols come out.

following are my codes, how should i change it to make it work?

any tips are appreciated.

thanks,

wantime
-------------------------------------------------------------
--------------------------------------------------------------
procedure TForm1.LoadShortStingClick(Sender: TObject);
var
  ID: String[10];
begin
  aStream := TFileStream.Create(mpath, fmOpenRead);
  aStream.Read(ID[1], 10);
  Edit2.text := ID;
  aStream.Free;
end;

procedure TForm1.SaveShortStingClick(Sender: TObject);
var
  S: String[10];
begin

  S[1] := 'A';
  S[2] := 'B';
  S[3] := 'C';
  S[4] := 'D';
  S[5] := 'E';
  S[6] := 'F';
  S[7] := 'G';
  S[8] := 'H';
  S[9] := 'I';
  S[10] := 'J';

  aStream := TFileStream.Create(mpath, fmCreate);
  aStream.Write(S[1], 10);

  aStream.Free;
end;
ASKER CERTIFIED SOLUTION
Avatar of MerijnB
MerijnBFlag of Netherlands imageSr. Software Engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 14 Comments.
See Answers