Click here to Skip to main content
16,016,789 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
XML
<b>Error    1    System.IO.StreamReader' does not contain a definition for 'close' </b>   ...is that so . update this with the correct code..
//
  if(!Page.IsPostBack)
        {
            StreamReader strmEditFile;
            try{
                //Open the file
                strmEditFile = File.OpenText(strPath + "\\" + strFile);
                //Read its text
                txtEditFile.Text = strmEditFile.ReadToEnd().ToString();
                //Close the file.
                strmEditFile.close();
            }
            catch(FileNotFoundException ex)
            {
                // If it does not exists . create it.
                File.CreateText(strPath + "\\" + strFile).Close();
                //Clear the text Box
                txtEditFile.Text = "";
            }
            catch(System.UnauthorizedAccessException ex)
            {
                Server.Transfer("NotAuthorized.aspx");
            }
<b><u>
and u 9 what catch  block is also showing error that ex(object) is declared but not used here ,,,,
Please guide as earliest as possible</u></b>
--
Posted
Comments
Sergey Alexandrovich Kryukov 2-May-11 7:13am    
Is your Intellisense broken? Don't right all by hand, use Intellisense... how about Microsoft naming conventions? They help. (Camel case, Capitalized...).
--SA

1 solution

System.IO.StreamReader' does not contain a definition for 'close'
As error message is stating System.IO.StreamReader does not have "close" method. You have just made mistake with Caps "C". it's "Close"

strmEditFile.Close();


Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900