public MainPage()
        {
            InitializeComponent();
            StreamReader read = new StreamReader("T1.txt");
            string rr = read.ReadLine();
            textBlock1.Text = rr;
        }
    }

when it start debuging it's stop here: string rr = read.ReadLine();
it's give me an method ccess exception how can i solve this problem??

Edited 3 Years Ago by Dani: Formatting fixed

You usually get this exception if you try to access a private method.
Could you give us the complete error message?

ddanbe it's start debuging then stop at this line:string rr = read.ReadLine();

and give me a box contain
Attempt to access the method failed: System.IO.StreamReader..ctor(System.String);
i tried using try & catch but nothing worked:(

You usually get this exception if you try to access a private method.
Could you give us the complete error message?

ddanbe it's start debuging then stop at this line:string rr = read.ReadLine();

and give me a box contain
Attempt to access the method failed: System.IO.StreamReader..ctor(System.String);
i tried using try & catch but nothing worked.

Do you have the .txt file open with any other program (sharing violation)?
Can you post the text of what you captured in the exception

try
{
   //...
}
catch(Exception exc)
{
   System.Diagnostics.Debug.WriteLine(exc.Message); // or StackTrace //
}

Do you have the .txt file open with any other program (sharing violation)?
Can you post the text of what you captured in the exception

try
{
   //...
}
catch(Exception exc)
{
   System.Diagnostics.Debug.WriteLine(exc.Message); // or StackTrace //
}

thanx
it's work but i wanna read the file content to my page but it dosent work the file exist at same pth with my project so how can i solve this:??

This article has been dead for over six months. Start a new discussion instead.