How to open all *.txt to a listbox [closed]











up vote
-1
down vote

favorite












I need to open the contents of these files in the ListBox (a folder with many *.txt files). I would like to know a way to load all text files that are in that folder into a ListBox. I need to open all .txt files in listbox with a just click or procedure.










share|improve this question















closed as too broad by Remy Lebeau, Sertac Akyuz, Vega, Ken White, David Heffernan Nov 22 at 7:08


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 1




    Emumerate the files, open each one, read its content, add to ListBox. Which step is confusing you exactly? Please be more specific.
    – Remy Lebeau
    Nov 22 at 2:09










  • A listbox consists of items, not exactly suitable to display text files.
    – Sertac Akyuz
    Nov 22 at 2:57










  • It is not necessary to put help in your title. It's clear you need help or you wouldn't be posting here. It's also not necessary to repeat the tag information in the title - the tagging system works very well here and doesn't need extra help. It would be of great benefit to you in terms of your experiences here if you spend some time taking the tour and reading the help center pages, especially How to Ask, before you start posting here.
    – Ken White
    Nov 22 at 4:37












  • okay sorry Thanks for the tips, I'll do it.
    – William Miguel
    Nov 22 at 12:41















up vote
-1
down vote

favorite












I need to open the contents of these files in the ListBox (a folder with many *.txt files). I would like to know a way to load all text files that are in that folder into a ListBox. I need to open all .txt files in listbox with a just click or procedure.










share|improve this question















closed as too broad by Remy Lebeau, Sertac Akyuz, Vega, Ken White, David Heffernan Nov 22 at 7:08


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 1




    Emumerate the files, open each one, read its content, add to ListBox. Which step is confusing you exactly? Please be more specific.
    – Remy Lebeau
    Nov 22 at 2:09










  • A listbox consists of items, not exactly suitable to display text files.
    – Sertac Akyuz
    Nov 22 at 2:57










  • It is not necessary to put help in your title. It's clear you need help or you wouldn't be posting here. It's also not necessary to repeat the tag information in the title - the tagging system works very well here and doesn't need extra help. It would be of great benefit to you in terms of your experiences here if you spend some time taking the tour and reading the help center pages, especially How to Ask, before you start posting here.
    – Ken White
    Nov 22 at 4:37












  • okay sorry Thanks for the tips, I'll do it.
    – William Miguel
    Nov 22 at 12:41













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I need to open the contents of these files in the ListBox (a folder with many *.txt files). I would like to know a way to load all text files that are in that folder into a ListBox. I need to open all .txt files in listbox with a just click or procedure.










share|improve this question















I need to open the contents of these files in the ListBox (a folder with many *.txt files). I would like to know a way to load all text files that are in that folder into a ListBox. I need to open all .txt files in listbox with a just click or procedure.







delphi listbox delphi-7






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 8:57









Uli Gerhardt

11.9k13875




11.9k13875










asked Nov 22 at 1:47









William Miguel

32




32




closed as too broad by Remy Lebeau, Sertac Akyuz, Vega, Ken White, David Heffernan Nov 22 at 7:08


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as too broad by Remy Lebeau, Sertac Akyuz, Vega, Ken White, David Heffernan Nov 22 at 7:08


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    Emumerate the files, open each one, read its content, add to ListBox. Which step is confusing you exactly? Please be more specific.
    – Remy Lebeau
    Nov 22 at 2:09










  • A listbox consists of items, not exactly suitable to display text files.
    – Sertac Akyuz
    Nov 22 at 2:57










  • It is not necessary to put help in your title. It's clear you need help or you wouldn't be posting here. It's also not necessary to repeat the tag information in the title - the tagging system works very well here and doesn't need extra help. It would be of great benefit to you in terms of your experiences here if you spend some time taking the tour and reading the help center pages, especially How to Ask, before you start posting here.
    – Ken White
    Nov 22 at 4:37












  • okay sorry Thanks for the tips, I'll do it.
    – William Miguel
    Nov 22 at 12:41














  • 1




    Emumerate the files, open each one, read its content, add to ListBox. Which step is confusing you exactly? Please be more specific.
    – Remy Lebeau
    Nov 22 at 2:09










  • A listbox consists of items, not exactly suitable to display text files.
    – Sertac Akyuz
    Nov 22 at 2:57










  • It is not necessary to put help in your title. It's clear you need help or you wouldn't be posting here. It's also not necessary to repeat the tag information in the title - the tagging system works very well here and doesn't need extra help. It would be of great benefit to you in terms of your experiences here if you spend some time taking the tour and reading the help center pages, especially How to Ask, before you start posting here.
    – Ken White
    Nov 22 at 4:37












  • okay sorry Thanks for the tips, I'll do it.
    – William Miguel
    Nov 22 at 12:41








1




1




Emumerate the files, open each one, read its content, add to ListBox. Which step is confusing you exactly? Please be more specific.
– Remy Lebeau
Nov 22 at 2:09




Emumerate the files, open each one, read its content, add to ListBox. Which step is confusing you exactly? Please be more specific.
– Remy Lebeau
Nov 22 at 2:09












A listbox consists of items, not exactly suitable to display text files.
– Sertac Akyuz
Nov 22 at 2:57




A listbox consists of items, not exactly suitable to display text files.
– Sertac Akyuz
Nov 22 at 2:57












It is not necessary to put help in your title. It's clear you need help or you wouldn't be posting here. It's also not necessary to repeat the tag information in the title - the tagging system works very well here and doesn't need extra help. It would be of great benefit to you in terms of your experiences here if you spend some time taking the tour and reading the help center pages, especially How to Ask, before you start posting here.
– Ken White
Nov 22 at 4:37






It is not necessary to put help in your title. It's clear you need help or you wouldn't be posting here. It's also not necessary to repeat the tag information in the title - the tagging system works very well here and doesn't need extra help. It would be of great benefit to you in terms of your experiences here if you spend some time taking the tour and reading the help center pages, especially How to Ask, before you start posting here.
– Ken White
Nov 22 at 4:37














okay sorry Thanks for the tips, I'll do it.
– William Miguel
Nov 22 at 12:41




okay sorry Thanks for the tips, I'll do it.
– William Miguel
Nov 22 at 12:41












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










You can do something like this:



var
path: string;
SR: TSearchRec;
tempFile: TextFile;
line: string;
begin
path:= 'C: insert path to your folder';
if FindFirst(path + '*.txt', faAnyFile, SR) = 0 then
begin
repeat
if (SR.Attr <> faDirectory) then
begin
AssignFile(tempFile, path + SR.Name);
Reset(tempFile);
while not Eof(tempFile) do
begin
Readln(tempFile, line);
ListBox1.Items.Add(line);
end;
end;
until FindNext(SR) <> 0;
FindClose(SR);
end;
end;


Put it on the button click or wrap it into the procedure.






share|improve this answer





















  • Mr. Nice yeah, exactly what I needed! Thank you very much issue solved
    – William Miguel
    Nov 22 at 12:34












  • @WilliamMiguel you are welcome. If solved the problem you could accept the answer.
    – Mr. Nice
    Nov 22 at 12:49


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










You can do something like this:



var
path: string;
SR: TSearchRec;
tempFile: TextFile;
line: string;
begin
path:= 'C: insert path to your folder';
if FindFirst(path + '*.txt', faAnyFile, SR) = 0 then
begin
repeat
if (SR.Attr <> faDirectory) then
begin
AssignFile(tempFile, path + SR.Name);
Reset(tempFile);
while not Eof(tempFile) do
begin
Readln(tempFile, line);
ListBox1.Items.Add(line);
end;
end;
until FindNext(SR) <> 0;
FindClose(SR);
end;
end;


Put it on the button click or wrap it into the procedure.






share|improve this answer





















  • Mr. Nice yeah, exactly what I needed! Thank you very much issue solved
    – William Miguel
    Nov 22 at 12:34












  • @WilliamMiguel you are welcome. If solved the problem you could accept the answer.
    – Mr. Nice
    Nov 22 at 12:49















up vote
1
down vote



accepted










You can do something like this:



var
path: string;
SR: TSearchRec;
tempFile: TextFile;
line: string;
begin
path:= 'C: insert path to your folder';
if FindFirst(path + '*.txt', faAnyFile, SR) = 0 then
begin
repeat
if (SR.Attr <> faDirectory) then
begin
AssignFile(tempFile, path + SR.Name);
Reset(tempFile);
while not Eof(tempFile) do
begin
Readln(tempFile, line);
ListBox1.Items.Add(line);
end;
end;
until FindNext(SR) <> 0;
FindClose(SR);
end;
end;


Put it on the button click or wrap it into the procedure.






share|improve this answer





















  • Mr. Nice yeah, exactly what I needed! Thank you very much issue solved
    – William Miguel
    Nov 22 at 12:34












  • @WilliamMiguel you are welcome. If solved the problem you could accept the answer.
    – Mr. Nice
    Nov 22 at 12:49













up vote
1
down vote



accepted







up vote
1
down vote



accepted






You can do something like this:



var
path: string;
SR: TSearchRec;
tempFile: TextFile;
line: string;
begin
path:= 'C: insert path to your folder';
if FindFirst(path + '*.txt', faAnyFile, SR) = 0 then
begin
repeat
if (SR.Attr <> faDirectory) then
begin
AssignFile(tempFile, path + SR.Name);
Reset(tempFile);
while not Eof(tempFile) do
begin
Readln(tempFile, line);
ListBox1.Items.Add(line);
end;
end;
until FindNext(SR) <> 0;
FindClose(SR);
end;
end;


Put it on the button click or wrap it into the procedure.






share|improve this answer












You can do something like this:



var
path: string;
SR: TSearchRec;
tempFile: TextFile;
line: string;
begin
path:= 'C: insert path to your folder';
if FindFirst(path + '*.txt', faAnyFile, SR) = 0 then
begin
repeat
if (SR.Attr <> faDirectory) then
begin
AssignFile(tempFile, path + SR.Name);
Reset(tempFile);
while not Eof(tempFile) do
begin
Readln(tempFile, line);
ListBox1.Items.Add(line);
end;
end;
until FindNext(SR) <> 0;
FindClose(SR);
end;
end;


Put it on the button click or wrap it into the procedure.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 22 at 7:18









Mr. Nice

19511




19511












  • Mr. Nice yeah, exactly what I needed! Thank you very much issue solved
    – William Miguel
    Nov 22 at 12:34












  • @WilliamMiguel you are welcome. If solved the problem you could accept the answer.
    – Mr. Nice
    Nov 22 at 12:49


















  • Mr. Nice yeah, exactly what I needed! Thank you very much issue solved
    – William Miguel
    Nov 22 at 12:34












  • @WilliamMiguel you are welcome. If solved the problem you could accept the answer.
    – Mr. Nice
    Nov 22 at 12:49
















Mr. Nice yeah, exactly what I needed! Thank you very much issue solved
– William Miguel
Nov 22 at 12:34






Mr. Nice yeah, exactly what I needed! Thank you very much issue solved
– William Miguel
Nov 22 at 12:34














@WilliamMiguel you are welcome. If solved the problem you could accept the answer.
– Mr. Nice
Nov 22 at 12:49




@WilliamMiguel you are welcome. If solved the problem you could accept the answer.
– Mr. Nice
Nov 22 at 12:49



Popular posts from this blog

What visual should I use to simply compare current year value vs last year in Power BI desktop

Alexandru Averescu

Trompette piccolo