0

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

SiPex

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by mariocatch
0

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(_SR.ReadLine());
            }

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

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

Pre-200 #: 1

continuously Any other suggestions?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.