0

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

2
Contributors
1
Reply
11
Views
2 Years
Discussion Span
Last Post by Reverend Jim
0

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.

Edited by Reverend Jim

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.