TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ghazanfar khan
NA
18
0
problem with StreamReader
May 21 2007 1:08 PM
Hello! I am new to .NET. I'm trying to pick up some C#.net skills and make simple-moderate level websites. My problem is that a lot of the code samples I find on the web simply dont work on my machine. For example, here is a simple class that is supposed to read a text file ************************************************ public class Readtextfile { public static int Main(string[] args) { StreamReader re = File.OpenText("Arungg.txt"); string input = null; while ((input = re.ReadLine()) != null) { Console.WriteLine(input); } re.close; return 0; } } ************************************************ This is from a tutorial on the c-sharpcorner website --> http://www.c-sharpcorner.com/UploadFile/ggaganesh/CSAndTypes11092005011259AM/CSAndTypes.aspx I created a new asp.net website using "FileSystem" as the location and C# as the language. Then I added a new class called Readtextfile and copied the code, placing my text file in the correct directory. But I get the following errors with this 1. about re.close; only assignment, call, increment, decrement and new object expressions can be used as a statement. 2. about re.close 'System.IO.StreamReader' does not contain a definition for 'close' Ive added using System.IO; directive. I also tried putting this block of code in the aspx.cs under the Page_Load method. That didnt work either. If this problem sounds familiar to anyone, please reply back. If you dont have an answer, maybe we can figure it out together. Thanks everyone!
Reply
Answers (
2
)
C# Question
how to connect dataset with crystal report