| | |
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 2007 access activedirectory algorithm array barchart bitmap box broadcast buttons c# check checkbox client combobox connect control conversion cryptographyc#winformsencryption csharp custom database datagrid datagridview dataset datetime degrees development disabled displayingopenforms draganddrop drawing encryption enum event eventcloseformc# excel file foreach form format forms ftp function gdi+ httpwebrequest image index index-error input install java label list listbox load mandelbrot math mathematics mouseclick mysql operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting richtextbox server setup sleep socket sql statistics stream string table text textbox thread time timer totaldays update user usercontrol validation visualstudio webbrowser windows winforms wpf xml





