When I read in this file it reads in the entire line.

string filename ="f:\\date.txt";
            
            FileStream f = new FileStream(filename, FileMode.Open);
            StreamReader stream = new StreamReader(f);
            
            int line;
          

            int[] array = new int[15]; 
            for (int i = 0; i < 15; i++)
            {
               
                line = stream.Read();    // header line
                Console.WriteLine(line);
              
            }

The line it reads in from the file is 001 10:00 ON
How would I read the line if so 001 is as int, 10:00 is a string, and ON is a string?

Maybe this will do? :

string filename = "f:\\date.txt";
            using (StreamReader stream = new StreamReader(filename))
            { 
                string line;
                while ((line = stream.ReadLine()) != null)
                {
                    string[] array = line.Split(' ');
                    int a = Convert.ToInt32(array[0]); //1.
                    string b = array[1];               //2.
                    string c = array[2];               //3.
                }
            }

Edited 5 Years Ago by Mitja Bonca: n/a

Maybe this will do? :

string filename = "f:\\date.txt";
            using (StreamReader stream = new StreamReader(filename))
            { 
                string line;
                while ((line = stream.ReadLine()) != null)
                {
                    string[] array = line.Split(' ');
                    int a = Convert.ToInt32(array[0]); //1.
                    string b = array[1];               //2.
                    string c = array[2];               //3.
                }
            }

Thanks I never thought about splitting the string.

This question has already been answered. Start a new discussion instead.