Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 3rd, 2007, 04:16 AM
Registered User
Join Date: May 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default reading a stream from all the lines of a file

Hi, i want to read a data from a pipe separated file, the stream should read only upto first pipe separator n after that it should read data from second line in the same manner.
every time the data which is read is used to retrive some information from the database n it should happen till the file is completely read.

Old May 3rd, 2007, 07:49 AM
Authorized User
Join Date: Dec 2004
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to DZukiewicz

Well, its not fun giving the game away, but heres a start:

Firstly, you could read the file in as lines individually:

string[] lines = File.ReadAllLines(filename);

ArrayList extractedData = new ArrayList();

foreach(string line in lines)
     string extract = string.Empty;
     int position = line.IndexOf("|");
     if(position > -1)
          extract = line.Substring(0,position);


string[] extracts = new string[extractedData.Length];

//Do your database bits here.
Hope this helps.


Old May 10th, 2007, 01:44 AM
Registered User
Join Date: May 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts

it is giving an error, System.Collections.Arraylist() does not contain defination for "length"

Old May 10th, 2007, 02:33 AM
Registered User
Join Date: May 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts

just hv a look d way i tried is:

 FileStream fs = new FileStream("C:\\data.lst", FileMode.Open, FileAccess.Read);
 StreamReader reader = new StreamReader(fs);
 string str;
 str = reader.ReadLine().ToString();
 while (str =reader .ReadLine ()!=null )

                        String[] collection = str.Split('|');
                        string empid = collection[0];

and here database connection

bt in this also it's givin an error inwhile loop that, cannot convert bool to string and string to bool

Similar Threads
Thread Thread Starter Forum Replies Last Post
File stream Gridview to Excel yukijocelyn ASP.NET 2.0 Professional 0 October 1st, 2007 01:10 AM
Reading multiple lines as a single unit ravishakya Pro Java 0 September 14th, 2006 09:08 AM
Http file or stream post via JavaScript... playazklubb BOOK: Professional Ajax ISBN: 978-0-471-77778-6 4 May 2nd, 2006 09:07 PM
Adodb.stream File could not be opened. irabba Javascript 6 July 6th, 2004 06:25 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.