| | |
Read certain # of lines
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2007
Posts: 28
Reputation:
Solved Threads: 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
Any help would be appreciated
SiPex
Last edited by SiPexTBC; Nov 21st, 2007 at 8:25 pm.
•
•
Join Date: Apr 2007
Posts: 103
Reputation:
Solved Threads: 17
Try using StreamReader.
C# Syntax (Toggle Plain Text)
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(); } } }
![]() |
Similar Threads
- how to read a text file backwards? (C)
- Can't read what I am posting (DaniWeb Community Feedback)
- Program does not read through correctly (C)
- how to remove a number of lines from a text file ? (Python)
- Is it possible to arange lines in a file alphabetically? (C)
- help on using StringTokenizer to read and compute multiple lines from text (Java)
- Question about read method of InputStream (Java)
Other Threads in the C# Forum
- Previous Thread: Concatination in StringBuilder
- Next Thread: Question about a program I wrote?
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# check checkbox client color combo combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees developer development draganddrop drawing encryption enum equation event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener mandelbrot math mathematics mouseclick mysql nargalax operator path photoshop picturebox pixelinversion post programming radians regex remote remoting restore richtextbox save saving serialization server sleep socket sql stack statistics stream string table tcp text textbox thread time timer update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





