Question by
pricem · Jun 01, 2016 at 08:23 PM ·
c#reading data
Cycle through different txt files to update positions
I have my code set to instantiate spheres at predetermined x,y,z locations that are read from a txt file. My next step is to cycle through to the next file (they are named like: "data0000, data0001, etc.) over and over again until I run out of data. This is the segment of code that I want to do this. My idea was to turn my loop variable into a string and then just add it on to the end of the filename string (for runs with more than 10 data files I would have some if statements or something truncating the original filename to "data00" for j<100 and "data0" for j<1000).
for (int j = 0; j < 10; j++)
{
string filename;
filename = "data000";
string jstring = j.ToString();
filename = filename + jstring;
Debug.Log(filename);
using (StreamReader sr = new StreamReader("./Assets/outputs/"+filename+".txt"))
Comment