Hi,

i have a txt file that i want to read from the program and add it to a queue.
how to i read part of the file (say for ex 50 characters each) and put it to a queue.
the file contains a story.

 string filePath = "C:\\";

            try
            {
                using (StreamReader sr = new StreamReader(filePath + "file.txt"))
                {
                    String line = sr.ReadToEnd();
                    Console.WriteLine(line);
                    Console.ReadLine();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }

i got it to read it to the console how do i write to a queue.

appreciate a reply
thanks

Can do it with one line

Queue<String> myQueue = new Queue<String>(File.ReadAllLines(filePath + "file.txt"));
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.