0
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 by Dani: Formatting fixed

3
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by NPDA
1

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

0

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:(

0

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.

1

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 //
}
0

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.