| | |
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 algorithm alignment array barchart bitmap box broadcast buttons c# c#gridviewcolumn check checkbox client combobox communication control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing elevated encryption enum event excel file focus forloop form format forms function gdi+ hospitalmanagementsystem httpwebrequest image index input install java label list listbox localization login mandelbrot math messagebox mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox server sleep socket sql statistics stream string stringformatting sun table text textbox thread time timer update usercontrol validation visualstudio webbrowser whileloop windows winforms wpf xml





