| | |
reading a file from a specified place
Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
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
Views: 903 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button buttons c# chat check checkbox class client code combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms ftp function gcd gdi+ http httpwebrequest image index input install java label list listbox login mandelbrot math mysql networking operator oracle path photoshop picturebox pixelinversion prime programming radians regex remote remoting resource richtextbox save saving serialization server socket sql statistics stream string table tcp text textbox time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





