Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I get the error like File Operation is not permitted Access is denied while i am reading the .xaml file from my local machine.

What is the solution in Silverlight 4.

I use the below code..
C#
private void button1_Click(object sender, RoutedEventArgs e)
{

 OpenFileDialog Fd = new OpenFileDialog();
                Fd.ShowDialog();

                Fd.Filter = "xaml|*.xaml";

                string LoadedFileName = Fd.File.Name;
                //Load the file    
                FileStream Fs = new FileStream(@LoadedFileName, FileMode.Open);
                      .
                      .
}
Posted
Updated 21-Aug-12 19:10pm
v2
Comments
Varun Sareen 22-Aug-12 1:16am    
try to check the permission on the folder containing the file; I think the folder is not in share mode.

1 solution

C#
FileStream Fs = FD.OpenFile();
is sufficient, but this would be read-only...

C#
private void button1_Click(object sender, RoutedEventArgs e)
{
     OpenFileDialog FD = new OpenFileDialog();
     FD.Filter = "XAML Files (*.xaml)|*.xaml";
     if(FD.ShowDialog() == DialogResult.OK)
     {       
        string fileName = FD.FileName;
        if (File.Exists(fileName))
        {
            FileStream Fs = new FileStream(fileName, FileMode.Open);
        }
     }
}
 
Share this answer
 
v3
Comments
ridoy 22-Aug-12 2:04am    
exact answer..+5

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