We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Workshop Alex - Read/Write StringList to File

Romans
Romans asked
on
Medium Priority
368 Views
Last Modified: 2010-04-05
Workshop Alex,
I found your code on the website and it will be very useful to me. Can you help me with reading the stringlist from teh file that this code creates?

     http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21202977.html?query=save+stringlist+to+file&topics=85

Thanks



var
  I:Integer;
  Output:TextFile;
  {List:TStringList;}
begin
  AssignFile( Output, 'Filename.txt' ) );
  Rewrite( Output );
  if ( List.Count > 0 ) then begin
    for I := 0 to Pred( Pred( List.Count ) ) do begin
      WriteLn( Output, List[ I ] );
    end;
    Write( Output, List[ Pred( List.Count ) ] );
  end;
  CloseFile( Output );
end;
Comment
Watch Question

Mike LittlewoodEngineer

Commented:
You do know that a stringlist has its own save and load from file properties yes?
This would be much quicker to use if going directly from a stringlist.

Author

Commented:
No I didn't know that. I am looking t that now ..
StringList.LoadFromFile('c:\lines.txt');
StringList.SaveToFile('c:\lines.txt');

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.