We help IT Professionals succeed at work.
Get Started

Read/Save TXT files

jrmn asked
Last Modified: 2010-04-05
Hi Experts,

Using an editbox to enter a valid directory path, how will I do it in Delphi6 that will scan this directory for all occurance of .TXT files. For each TXT file, will then scan for a given word. If found, will then save the filename to another TXT file.
Say if directory is 'C:\temp\', and there are 10 TXT files found here, it will then scan each of these files for any occurance of the word say "Delphi". For each TXT file that contains the given word, it will then write it to a TXT file (say mytext.txt) the filename and the line where the word "Delphi" was first found.
It will be something like this:

If only 5 TXT files contains the word "Delphi", MYTEXT.TXT, when you open it, the contains will be:

TEXT1.TXT, line 2
TEXT4.TXT, line 40
TEXT5.TXT, line 23
TEXT8.TXT, line 12
TEXT9.TXT, line 100

Can this be done?

Watch Question
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE