Hi Dw

I want to read a text file line by line and refer to those lines, meaning the text file will have 1 word per line and these words are the names which will be used by a scanner to check if there are any files named as these words on a system and if the file is found be removed, the main part that I want is to read the text file line by line and use each word to check if there is a file named like that or there is a file with that name.

The text file will contain many lines.

Anyone know how can I do this?
Thank you

The easiest way is

For Each filename As String In System.IO.File.ReadAllLines(MyFile)
    MyCustomSub(filename)
Next

Just add your file processing code in MyCustomSub. Some people would suggest you use a StreamReader but the file would have to be enormous before memory is a consideration and the above method means you don't have to bother checking for things like end of file. The code is clear and straightforward.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.