0
private void Button4_Click(object sender, EventArgs e) 
        {
            //Finding your file and assigning it as a string.
            string start = Directory.GetCurrentDirectory() + @"\file.txt";

            using (var streamReader = new StreamReader(start))
            {
                string line = streamReader.ReadLine();

                int[] values = line.Split(' ').Select(int.Parse).ToArray();

                Array.Sort(values);

                Array.Reverse(values);

                for (int i = 0; i < values.Length; i++)
                {
                    richTextBox4.AppendText(values[i] + " ");
                }
            }
        }

So i need to get access to 8-9-10 lines and my .txt file is: https://gyazo.com/7ac43e9c5a4cb4d17393e429657778ae

Also 8-9-10 lines have to be like this:

28 80 62 30 68 77 71 64 54 84 57 37, 

in one line.

Dmitry Bychenko
  • 180,369
  • 20
  • 160
  • 215
Harry
  • 11
  • It is not clear, at least not to me, what do you mean with "i need to get access to", do you have read problems to the file? Also, you should consider editing your question and adding the file sample in the question body, not as an external link. – Cleptus Dec 02 '19 at 14:18

1 Answers1

3

If you want to Skip first 7 lines, you can do it with a help of Linq:

   using System.IO;
   using System.Linq;

   ...

   private void Button4_Click(object sender, EventArgs e) {
     var numbers = File
       .ReadLines(Path.Combine(Directory.GetCurrentDirectory(), "file.txt"))
       .Skip(7)
    // .Take(3) // Uncomment it if you want to take at most 3 lines after skip
       .SelectMany(line => line.Split(' ')); 

     richTextBox4.Text = string.Join(" ", numbers);
   }
Dmitry Bychenko
  • 180,369
  • 20
  • 160
  • 215