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??

Recommended Answers

All 7 Replies

Use the full path to the file and see if it still happens.

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

thines01 dosent work too with full path:(

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.