473,466 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Reading in a text then using the data?

I am trying to read in a text file then use the data in the file.

I know how to read a file wiht the System.IO namespace:

FileRead fr = new StreamReader("data.txt");
Console.Writeline(fr.Readline());

or

StreamReader fr = File.OpenText("Data.txt");
string buffer = null
While ((buffer = re.Readline()) !+ null)
{
Console.Writeline(buffer);
}
fr.close;

But how do I use the data after it is read? In short, I would like to
store the data in a varabile.

Paul
Nov 2 '07 #1
3 1187
In short, I would like to store the data in a varabile.

You answered your own question in your example.

string buffer = null
buffer = re.ReadLine()

--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com
"Paul Lemelle" <Pl******@comcast.netwrote in message
news:so********************************@4ax.com...
>I am trying to read in a text file then use the data in the file.

I know how to read a file wiht the System.IO namespace:

FileRead fr = new StreamReader("data.txt");
Console.Writeline(fr.Readline());

or

StreamReader fr = File.OpenText("Data.txt");
string buffer = null
While ((buffer = re.Readline()) !+ null)
{
Console.Writeline(buffer);
}
fr.close;

But how do I use the data after it is read? In short, I would like to
store the data in a varabile.

Paul
Nov 2 '07 #2
Hi,
It seems like you are probably stuck breaking up the line of data into
its component parts.
If the fields are fixed length then you can simply use
mystring,Substring(n,y)
If not see if the data lends itself to the use of Regular expressions
to capture its component parts.

hth
Bob

On Thu, 01 Nov 2007 21:19:09 -0600, Paul Lemelle
<Pl******@comcast.netwrote:
>I am trying to read in a text file then use the data in the file.

I know how to read a file wiht the System.IO namespace:

FileRead fr = new StreamReader("data.txt");
Console.Writeline(fr.Readline());

or

StreamReader fr = File.OpenText("Data.txt");
string buffer = null
While ((buffer = re.Readline()) !+ null)
{
Console.Writeline(buffer);
}
fr.close;

But how do I use the data after it is read? In short, I would like to
store the data in a varabile.

Paul
Nov 2 '07 #3
Thanks, and I think that that should do the trick.
Paul
On Fri, 02 Nov 2007 19:59:40 +1300, bob clegg
<cu**********@remooove.xtra.co.nzwrote:
>Hi,
It seems like you are probably stuck breaking up the line of data into
its component parts.
If the fields are fixed length then you can simply use
mystring,Substring(n,y)
If not see if the data lends itself to the use of Regular expressions
to capture its component parts.

hth
Bob

On Thu, 01 Nov 2007 21:19:09 -0600, Paul Lemelle
<Pl******@comcast.netwrote:
>>I am trying to read in a text file then use the data in the file.

I know how to read a file wiht the System.IO namespace:

FileRead fr = new StreamReader("data.txt");
Console.Writeline(fr.Readline());

or

StreamReader fr = File.OpenText("Data.txt");
string buffer = null
While ((buffer = re.Readline()) !+ null)
{
Console.Writeline(buffer);
}
fr.close;

But how do I use the data after it is read? In short, I would like to
store the data in a varabile.

Paul
Nov 4 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dariusz | last post by:
Below is part of a code I have for a database. While the database table is created correctly (if it doesn't exist), and data is input correctly into the database when executed, I have a problem...
1
by: fabrice | last post by:
Hello, I've got trouble reading a text file (event viewer dump) by using the getline() function... After 200 - 300 lines that are read correctly, it suddenly stops reading the rest of the...
2
by: Roland Hall | last post by:
I have two(2) issues. I'm experiencing a little difficulty and having to resort to a work around. I already found one bug, although stated the bug was only in ODBC, which I'm not using. It...
1
by: Magnus | last post by:
allrite folks, got some questions here... 1) LAY-OUT OF REPORTS How is it possible to fundamentaly change the lay-out/form of a report in access? I dont really know it that "difficult", but...
21
by: JoKur | last post by:
Hello, First let me tell you that I'm very new to C# and learning as I go. I'm trying to write a client application to communicate with a server (that I didn't write). Each message from the...
7
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should...
4
by: Amit Maheshwari | last post by:
I need to read text file having data either comma seperated or tab seperated or any custom seperator and convert into a DataSet in C# . I tried Microsoft Text Driver and Microsoft.Jet.OLEDB.4.0...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
11
by: Freddy Coal | last post by:
Hi, I'm trying to read a binary file of 2411 Bytes, I would like load all the file in a String. I make this function for make that: '-------------------------- Public Shared Function...
4
by: Shark | last post by:
Hi, I need a help. My application reads data from COM port, this data is then parsed and displyed on: 1. two plotters 2. text box. I'm using Invoke method to update UI when new data is...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.