0

I have a Text file with several different C:\ locations i need, the idea is to use the streamreader to read the text file, load each line into an array and then be able to use that specific array per line in the Sub routines to code.

the idea, is that if in the future the location of the C:\ changes, there is no need to go into the code, just modify the information on that txt file and that would be it...

have tried several ways but no luck...

text file info looks like

d1="C:\displaydata\d1.html" d2="C:\displaydata\d2.html" d3="C:\displaydata\head.html" d4="C:\displaydata\nodata.html" d5="C:\readdata\d1.html"
an example of a routine is:

If My.Computer.FileSystem.FileExists(C:\displaydata\d1.html) = True Then My.Computer.FileSystem.MoveFile(C:\displaydata\d1.html, "C:\readdata\d1.html") End If
again, i do not want to use Dim d1 as string = "C:...." since the idea is to modify the txt file and that updates the new location in C:\

2
Contributors
1
Reply
5
Views
1 Year
Discussion Span
Last Post by tinstaafl
0

Reading all the lines into an array is easily accomplished with the File class, which is part of the IO namespace, and includes a ReadAllLines functions that returns a string array containing all lines in the file. From that point it's a relatively easy matter to iterate through the array and parse each line. The Path class, which is also included in the IO namespace, can parse a string to create a file path. This allows changing source directories or filename to create a new path.

Edited by tinstaafl

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.