Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 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 April 19th, 2005, 08:57 AM
Authorized User
 
Join Date: Feb 2005
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default Compiler error : displaying a text file

I am using the folowing code to display the contents of a text file in a web form. I get "type or namespace definition, or end of file expected" and "{ expected". I am new to this, can some help? Thank you. Joe

namespace WebApplication8
{
    /// <summary>
    ///
    /// </summary>
    public class readf
    {
        public readf()
        {
            //
            // TODO: Add constructor logic here
            public string ReadFromFile(string path, string fileName)
            {
                System.IO.StreamReader sr = File.OpenText("c:\\comcatch\\blah.txt");
                String text = sr.ReadToEnd();
                sr.Close();

                return text;
            }
        }
    }

}



 
Old April 19th, 2005, 10:51 AM
Authorized User
 
Join Date: Feb 2005
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I withdraw my own question. I am using different code and getting close to what I want.Apologies.
Joe

 
Old April 20th, 2005, 09:57 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

for working on un-managed resources like here you should always write your codes in a way to assure you finally you'r freeing them(here the handle to the file)
so declare the stream in using keyword or..

_____________
Mehdi.
software student.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler linker error raja_welcomes Visual C++ 1 June 6th, 2007 11:17 AM
old compiler seems to work but still is 1 error stevecist ASP.NET 1.0 and 1.1 Basics 1 January 24th, 2007 06:59 PM
Displaying a text file in a web form. boksi ASP.NET 1.0 and 1.1 Basics 1 April 18th, 2005 10:54 AM





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