IT Community - Software Programming, Web Development and Technical Support

reading data from a file using C#

This is a discussion on reading data from a file using C# within the C# Programming forums, part of the Software Development category; How to read a data in a file using C#?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-30-2007, 01:08 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Question reading data from a file using C#

How to read a data in a file using C#?
__________________
The OXYGEN
Delivers edgy, intelligent Technology to all...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-30-2007, 01:12 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: How to read a data in a file using C#?

Hi...
Use the following coding for read a data in a file using C#.

fs = new FileStream("log.txt", FileMode.OpenOrCreate, FileAccess.Read);

StreamReader r = new StreamReader(fs);
r.BaseStream.Seek(0, SeekOrigin.Begin);
DumpLog( r );

public static void DumpLog (StreamReader r)
{
while (r.Peek() > -1)
{
// While not at the end of the file, write to standard output.
Console.WriteLine(r.ReadLine());
}
r.Close();
}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-23-2007, 01:48 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: How to read a data in a file using C#?

Hi buddy,

Use as follows,

string[] str = File.ReadAllLines(@"C:/test.txt");
if (str.Length > 0)
{
for (int i = 0; i < str.Length; i++)
{
MessageBox.Show(str[i]);
}
}
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading IPTC data from Nikon camera RAW images,JPEG,TIFF files using Adobe dll in C# oxygen C# Programming 1 02-28-2008 11:33 PM
Reading and Writing to File using UTL_FILE in ORACLE Murali Database Support 2 08-23-2007 11:12 PM
Which is faster- Reading word size data whose starting address is at even or at odd a Arun Computer Hardware 0 07-18-2007 09:03 AM
Reading and writing EXIF meta data from jpg/jpeg,tiff images oxygen C# Programming 0 07-15-2007 11:24 PM
Reading WMV file meta data in .Net oxygen C# Programming 0 07-15-2007 11:18 PM


All times are GMT -7. The time now is 01:13 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0