| | |
StreamReaderClass
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
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.
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.
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
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:
3. Read from it, into a string:
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.
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:
ASP.NET Syntax (Toggle Plain Text)
StreamReader sr = new StreamReader("TestFile.txt");
3. Read from it, into a string:
ASP.NET Syntax (Toggle Plain Text)
string line; while ((line = sr.ReadLine()) != null) { //Do Something }
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.
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
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#
VB.NET
C#
ASP.NET Syntax (Toggle Plain Text)
using System.IO;
VB.NET
ASP.NET Syntax (Toggle Plain Text)
Imports System.IO
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: Get submitted values when navigating back with browser back button
- Next Thread: Server Error message when opening asp.net applicationm
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox class click commonfunctions compatible confirmationcodegeneration content contenttype countryselector courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dropdownmenu edit expose flash flv formatdecimal forms formview gridview homeedition iframe iis javascript jquery list listbox login menu microsoft mono mouse mssql multistepregistration nameisnotdeclared news numerical objects order panelmasterpagebuttoncontrols problem radio ratings rotatepage save schoolproject search security serializesmo.table silverlight smartcard sql sql-server sqlserver2005 suse textbox tracking unauthorized validation vb.net video videos virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopemnt webservice wizard xml youareanotmemberofthedebuggerusers






