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












-2















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 '18 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 '18 at 2:09











  • A listbox consists of items, not exactly suitable to display text files.

    – Sertac Akyuz
    Nov 22 '18 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 '18 at 4:37













  • okay sorry Thanks for the tips, I'll do it.

    – William Miguel
    Nov 22 '18 at 12:41
















-2















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 '18 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 '18 at 2:09











  • A listbox consists of items, not exactly suitable to display text files.

    – Sertac Akyuz
    Nov 22 '18 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 '18 at 4:37













  • okay sorry Thanks for the tips, I'll do it.

    – William Miguel
    Nov 22 '18 at 12:41














-2












-2








-2








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 '18 at 8:57









Uli Gerhardt

12k13878




12k13878










asked Nov 22 '18 at 1:47









William MiguelWilliam Miguel

32




32




closed as too broad by Remy Lebeau, Sertac Akyuz, Vega, Ken White, David Heffernan Nov 22 '18 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 '18 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 '18 at 2:09











  • A listbox consists of items, not exactly suitable to display text files.

    – Sertac Akyuz
    Nov 22 '18 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 '18 at 4:37













  • okay sorry Thanks for the tips, I'll do it.

    – William Miguel
    Nov 22 '18 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 '18 at 2:09











  • A listbox consists of items, not exactly suitable to display text files.

    – Sertac Akyuz
    Nov 22 '18 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 '18 at 4:37













  • okay sorry Thanks for the tips, I'll do it.

    – William Miguel
    Nov 22 '18 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 '18 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 '18 at 2:09













A listbox consists of items, not exactly suitable to display text files.

– Sertac Akyuz
Nov 22 '18 at 2:57





A listbox consists of items, not exactly suitable to display text files.

– Sertac Akyuz
Nov 22 '18 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 '18 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 '18 at 4:37















okay sorry Thanks for the tips, I'll do it.

– William Miguel
Nov 22 '18 at 12:41





okay sorry Thanks for the tips, I'll do it.

– William Miguel
Nov 22 '18 at 12:41












1 Answer
1






active

oldest

votes


















1














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 '18 at 12:34













  • @WilliamMiguel you are welcome. If solved the problem you could accept the answer.

    – Mr. Nice
    Nov 22 '18 at 12:49











  • Mr. Nice hey, I have a question.. i having some problems. I've been seeing a message lately "cannot create file ('c:file.txt') the process cannot acess the file cuz it is being used by another process" how do I free memory of these .txt files?

    – William Miguel
    Feb 2 at 0:45











  • why would you create file that already exists? you should just load file and not create it. stackoverflow.com/a/7830730/5789624

    – Mr. Nice
    Feb 4 at 6:55


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














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 '18 at 12:34













  • @WilliamMiguel you are welcome. If solved the problem you could accept the answer.

    – Mr. Nice
    Nov 22 '18 at 12:49











  • Mr. Nice hey, I have a question.. i having some problems. I've been seeing a message lately "cannot create file ('c:file.txt') the process cannot acess the file cuz it is being used by another process" how do I free memory of these .txt files?

    – William Miguel
    Feb 2 at 0:45











  • why would you create file that already exists? you should just load file and not create it. stackoverflow.com/a/7830730/5789624

    – Mr. Nice
    Feb 4 at 6:55
















1














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 '18 at 12:34













  • @WilliamMiguel you are welcome. If solved the problem you could accept the answer.

    – Mr. Nice
    Nov 22 '18 at 12:49











  • Mr. Nice hey, I have a question.. i having some problems. I've been seeing a message lately "cannot create file ('c:file.txt') the process cannot acess the file cuz it is being used by another process" how do I free memory of these .txt files?

    – William Miguel
    Feb 2 at 0:45











  • why would you create file that already exists? you should just load file and not create it. stackoverflow.com/a/7830730/5789624

    – Mr. Nice
    Feb 4 at 6:55














1












1








1







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 '18 at 7:18









Mr. NiceMr. Nice

237112




237112













  • Mr. Nice yeah, exactly what I needed! Thank you very much issue solved

    – William Miguel
    Nov 22 '18 at 12:34













  • @WilliamMiguel you are welcome. If solved the problem you could accept the answer.

    – Mr. Nice
    Nov 22 '18 at 12:49











  • Mr. Nice hey, I have a question.. i having some problems. I've been seeing a message lately "cannot create file ('c:file.txt') the process cannot acess the file cuz it is being used by another process" how do I free memory of these .txt files?

    – William Miguel
    Feb 2 at 0:45











  • why would you create file that already exists? you should just load file and not create it. stackoverflow.com/a/7830730/5789624

    – Mr. Nice
    Feb 4 at 6:55



















  • Mr. Nice yeah, exactly what I needed! Thank you very much issue solved

    – William Miguel
    Nov 22 '18 at 12:34













  • @WilliamMiguel you are welcome. If solved the problem you could accept the answer.

    – Mr. Nice
    Nov 22 '18 at 12:49











  • Mr. Nice hey, I have a question.. i having some problems. I've been seeing a message lately "cannot create file ('c:file.txt') the process cannot acess the file cuz it is being used by another process" how do I free memory of these .txt files?

    – William Miguel
    Feb 2 at 0:45











  • why would you create file that already exists? you should just load file and not create it. stackoverflow.com/a/7830730/5789624

    – Mr. Nice
    Feb 4 at 6:55

















Mr. Nice yeah, exactly what I needed! Thank you very much issue solved

– William Miguel
Nov 22 '18 at 12:34







Mr. Nice yeah, exactly what I needed! Thank you very much issue solved

– William Miguel
Nov 22 '18 at 12:34















@WilliamMiguel you are welcome. If solved the problem you could accept the answer.

– Mr. Nice
Nov 22 '18 at 12:49





@WilliamMiguel you are welcome. If solved the problem you could accept the answer.

– Mr. Nice
Nov 22 '18 at 12:49













Mr. Nice hey, I have a question.. i having some problems. I've been seeing a message lately "cannot create file ('c:file.txt') the process cannot acess the file cuz it is being used by another process" how do I free memory of these .txt files?

– William Miguel
Feb 2 at 0:45





Mr. Nice hey, I have a question.. i having some problems. I've been seeing a message lately "cannot create file ('c:file.txt') the process cannot acess the file cuz it is being used by another process" how do I free memory of these .txt files?

– William Miguel
Feb 2 at 0:45













why would you create file that already exists? you should just load file and not create it. stackoverflow.com/a/7830730/5789624

– Mr. Nice
Feb 4 at 6:55





why would you create file that already exists? you should just load file and not create it. stackoverflow.com/a/7830730/5789624

– Mr. Nice
Feb 4 at 6:55





Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents