| | |
reading a file from a specified place
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 58
Reputation:
Solved Threads: 9
In this case I would load all the string data into a variable so you can use the StringReader class (in System.IO).
The StringReader object lets you read a text file line by line. So you could scan through the lines in search of your delimeters and only read the lines in between when you have found the appropriate start and stop reading when it finds the end.
The StringReader object lets you read a text file line by line. So you could scan through the lines in search of your delimeters and only read the lines in between when you have found the appropriate start and stop reading when it finds the end.
Visual C# Kicks - Free C# code resources and articles.
•
•
Join Date: Jul 2008
Posts: 39
Reputation:
Solved Threads: 4
A standard piece of code I find myself using and reusing, time and time again...
C# Syntax (Toggle Plain Text)
using ( FileStream fileStream = File.OpenRead(CONFIG_PATH) ) { Regex entryRegex = new Regex(@"^\s*(?<name>\S+?)\s*\:\s*(?<value>.+?)\s*$", RegexOptions.Compiled | RegexOptions.IgnoreCase); using ( StreamReader reader = new StreamReader(fileStream) ) { while ( (line = reader.ReadLine()) != null ) { if ( entryRegex.IsMatch(line) ) { ...
![]() |
Similar Threads
- Replace words in a file (Python)
- Setting an array and reading in a txt file backwards (C++)
- What errors can occur while reading a file? (C)
- Updating a file: setting the offset (Perl)
- First year assigment on reading file, sorting and outputting invoice (C++)
- CSV file (C)
- trouble with counting letter from file, please help. (C++)
- reading in a file into a 2d array (C++)
- Having roblems using PHP to send info as text file (PHP)
- File parsing in 'C' (C)
Other Threads in the C# Forum
- Previous Thread: C# and VBA problem....
- Next Thread: Windows application on a server
| Thread Tools | Search this Thread |
.net 2007 access ado.net algorithm array barchart bitmap box broadcast buttons c# check checkbox client color combobox control conversion csharp custom database databaseconnection datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format formbox forms function gdi+ httpwebrequest image index input install java label list listbox listener mandelbrot math mouseclick msword mysql opening operator parse path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox round saving serialization server sleep socket sql statistics stream string table tcp temperature text textbox thread time timer update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





