I have a program that reads an sql file and then executes it into the mysql database. The problem is that when a file larger than 1 mb is executed, an error comes up saying the file is too large. Is there anyway that i can read, say 200 lines of the file, and execute that?

Any help would be appreciated


Try using StreamReader.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ReadLines
    class Program

        static void Main(string[] args)

            using (StreamWriter _SW = new StreamWriter("File.txt"))
                for (int i = 0; i < 200; i++)
                    _SW.WriteLine("Pre-200 #: " + i);
                for (int i = 0; i < 50; i++)
                    _SW.WriteLine("Post-200 #: " + i);

            using (StreamReader _SR = new StreamReader("File.txt", Encoding.UTF8))
                for(int i = 0; i < 200; i++)

            Console.WriteLine("\n\n\nPress any key to exit");

Hrm.. i used that exact code but, i get a text file full of

Pre-200 #: 1

continuously Any other suggestions?

Then you aren't using the exact same code. Because I get the correct output.