| | |
Read text file to a certain point
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
Ok so i want my program to read a text file to a certain point. Lets say to the line line that says fn: i then want it to read the one line only and only the the text after fn: and i want it to shoew that text in a text box. i no it can be done. but i dont know how. if any body knows would you min sharing
-T
-T
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
•
•
Join Date: Dec 2003
Posts: 55
Reputation:
Solved Threads: 6
C# Syntax (Toggle Plain Text)
StreamReader sr = new StreamReader("yourFileNameGoesHere", System.Text.Encoding.Default); string s = null; while ((s = sr.ReadLine()) != null) { if (s.IndexOf("fn:") != -1) { // ok, you found it // now you can do like // textBox1.text = s; break; } } sr.Close();
Thank you so much, man you have helped me learn C# so much. I really thank you for all of your help.
-T
-T
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
•
•
•
•
Originally Posted by tayspen
Thank you so much, man you have helped me learn C# so much. I really thank you for all of your help.
-T
Firefox
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Ewido
Tune up windows
Get detailed system information
My Fixes
Member - Alliance of Security Analysis Professionals - Since 2006
Grretings:
Just remove that part from the string:
the remove method takes two parameter, the index where you want to start removing and length you wish to remove
Just remove that part from the string:
C# Syntax (Toggle Plain Text)
s.Remove(0,3);
•
•
Join Date: Aug 2008
Posts: 1
Reputation:
Solved Threads: 0
Hi
Complete code to reading last line in text file
StreamReader streamReader = new StreamReader("HereWillBeYourTextFilePath");
ArrayList lines = new ArrayList();
string line;
while ((line = streamReader.ReadLine()) != null)
{
lines.Add(line);
}
streamReader.Close();
if (lines.Count > 0)
{
Response.Write(lines[lines.Count - 1].ToString());
}
===============
Complete code to reading last line in text file
StreamReader streamReader = new StreamReader("HereWillBeYourTextFilePath");
ArrayList lines = new ArrayList();
string line;
while ((line = streamReader.ReadLine()) != null)
{
lines.Add(line);
}
streamReader.Close();
if (lines.Count > 0)
{
Response.Write(lines[lines.Count - 1].ToString());
}
===============
![]() |
Similar Threads
- read text file (C)
- read text file (C#)
- using a "for" loop to read a text file (VB.NET)
- Read in a string from a text file (C)
- how do i read the last line of a text file? (Python)
- need help... how to file open client path text.. (PHP)
Other Threads in the C# Forum
- Previous Thread: Setup and deployment project problem
- Next Thread: How Insert Data Using EntityDataSource in FormView
| Thread Tools | Search this Thread |
.net 2007 access activedirectory algorithm array barchart bitmap box broadcast c# check checkbox client combobox control conversion cryptographyc#winformsencryption csharp custom database datagrid datagridview dataset date datetime degrees development disabled displayingopenforms draganddrop drawing encryption enum eventcloseformc# excel file foreach form format forms ftp function gdi+ image index index-error input install java label list listbox listener listview load mandelbrot math mathematics mouseclick mysql operator path photoshop picturebox pixelinversion post prime programming radians regex remoting richtextbox security server setup sleep socket sql statistics stream string table text textbox thread time timer totaldays update user usercontrol validation visual visualstudio webbrowser windows winforms wpf xml






