Board index » delphi » Saving List box + using SaveDialog

Saving List box + using SaveDialog

I have a memo box and i can save the contents of it with the following code:
TempStream := TMemoryStream.Create;
memo2.lines.savetostream(TempStream);
TempStream.savetofile('Clipboard.txt');
I also have a listbox that i need to save the contence of but i cannot get
it to save to a file, would someone tell me how to save the contence of a
list box to a txt file?
and one final question i made a SaveDialog to try and make saving the files
easier and i figured out SaveDialog1.Execute; activates the dialog but its
not saving any files how can i get it to save the text file on the memo box
& one for the list box?
Thank You
-
 

Re:Saving List box + using SaveDialog


Quote
"-" <-...@-.com> wrote in message

news:J78i9.1017$k27.90212@newsread1.prod.itd.earthlink.net...

Quote
> I have a memo box and i can save the contents of it with the following
code:
> TempStream := TMemoryStream.Create;
> memo2.lines.savetostream(TempStream);
> TempStream.savetofile('Clipboard.txt');
> I also have a listbox that i need to save the contence of but i cannot get
> it to save to a file, would someone tell me how to save the contence of a
> list box to a txt file?
> and one final question i made a SaveDialog to try and make saving the
files
> easier and i figured out SaveDialog1.Execute; activates the dialog but its
> not saving any files how can i get it to save the text file on the memo
box
> & one for the list box?
> Thank You

Dialogs do nothing! Remeber this. :-)
Method Execute just returns True if the user chosed Open/Save or False if
the user chosed Cancel (or pressed Escape or whatever). So your code that
saves the contents should go after Execute returns True. Like this:

If SaveDialog1.Execute then
    Memo2.Lines.SaveToFile('Clipboard.txt');

To save the contents of the Listbox use this:

Listbox1.Items.SaveToFile('Clipboard.txt');

And why do you use temporary streams when you can save directly to the file?

Other Threads