StreamReaderClass

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2005
Posts: 30
Reputation: augie0216 is an unknown quantity at this point 
Solved Threads: 0
augie0216's Avatar
augie0216 augie0216 is offline Offline
Light Poster

StreamReaderClass

 
0
  #1
May 26th, 2005
I'm doing an asp.net application but am using vb.net to code the example i'm working on. I'm creating a form that will show historic stock prices I have three description and value pairs:

Company Name stock symbol

Hartford har
Vertigo ver
Dickson dks

I have created three sequential files that have the same name as the symbol with the suffix of .txt. For example har.txt. They have the path c:\turbo.

The symbols are selected using a dropdownlist box.the user then clicks a submit button which makes the selected data apear in the mutiline textbox.

i'm really having a tough time trying to even find a way to start. could use some help.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: StreamReaderClass

 
0
  #2
May 26th, 2005
So this is a web app then, correct? Then the files should be in a folder accesible to the web app, not the root of your server.

Do you need help using StreamReader, then?
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 30
Reputation: augie0216 is an unknown quantity at this point 
Solved Threads: 0
augie0216's Avatar
augie0216 augie0216 is offline Offline
Light Poster

Re: StreamReaderClass

 
0
  #3
May 27th, 2005
Yes I need help with the streamReader. This is just a practice excercise and will not really be put on the web. The text files are on a shared folder that shouldn't be a problem. I've looked this up in two book I'm just not getting it.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: StreamReaderClass

 
0
  #4
May 27th, 2005
Ok, well, then ignoring all the details about web and shared folders, we'll focus just on StreamReader.

1. Import the correct namespace, which in this case would be: System.IO

2. Define the StreamReader. You can define in combination with its constructor. In C#, for example:

  1. StreamReader sr = new StreamReader("TestFile.txt");

3. Read from it, into a string:

  1. string line;
  2.  
  3. while ((line = sr.ReadLine()) != null)
  4. {
  5. //Do Something
  6. }

There are lots of variations. One thing I like to do is first create a FileStream object, and point that to my file. This gives me a lot of control over the access method, whether I want to share the file, and so on.

Then, I use a StreamReader constructor that creates a Streamreader from the FileStream.

Notes: Streamreader is buffered, so it's very fast, but you can often get lost in where you THINK the file is positioned, and where it actually IS positioned.

I'm sure you have more questions, just keep asking within this thread.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 30
Reputation: augie0216 is an unknown quantity at this point 
Solved Threads: 0
augie0216's Avatar
augie0216 augie0216 is offline Offline
Light Poster

Re: StreamReaderClass

 
0
  #5
May 28th, 2005
I can see I'm going to be asking a lot of questions. Since this is a asp.net I'm not sure how you import a namespace. Would this work:

Dim psrdCurrent as system.IO.Streamreader = New system.IO.StreamReader(path and file name to open)
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: StreamReaderClass

 
0
  #6
May 28th, 2005
ASP.NET or Windows Forms, it doesn't matter. Anything in the .NET Framework can be imported. It's a way of aliasing a namespace. You do it at the top of your program:

C#
  1. using System.IO;

VB.NET
  1. Imports System.IO
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC