* * *

Author Topic: TStringList.LoadFromFile  (Read 2653 times)

JLJR

  • Guest
TStringList.LoadFromFile
« on: July 16, 2005, 11:06:51 am »
Hi!. I'm trying what I think is a very simple thing, but it isn't works:

I have an TListBox into  a form and, when I press a button is executed the next instruction:

listbox1.items.loadfromfile('c:\autoexec.bat');

It should display the lines of autoexec.bat into the listbox, but doesn't work, the listbox is empty.

Do you think there is a lazarus mistake or (is most possible) i'm doing something bad?

Thank you very much.

carbohydrate

  • New member
  • *
  • Posts: 8
TStringList.LoadFromFile
« Reply #1 on: July 16, 2005, 12:31:45 pm »
I'm using Lazarus 0.9.8 and FreePascal 2.0 and it's working with the source code you have given:

procedure TForm1.Button1Click(Sender: TObject);
begin
  listbox1.items.loadfromfile('c:\autoexec.bat');
end;

Anonymous

  • Guest
TStringList.LoadFromFile
« Reply #2 on: July 16, 2005, 06:54:16 pm »
Thanks a lot.

I found the problem. My text file was saved as UNICODE instead of ANSI. It seems that LoadFromFile doesn't work fine with UNICOD files.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads