tags:

views:

36

answers:

1

Why make an exception in the code is not :

try
{

FileIOPermission FIP = new FileIOPermission(FileIOPermissionAccess.Write, @"c:\SD.txt");


FIP.Demand();//Exception must rise here

StreamWriter SW = new StreamWriter(@"c:\SD.txt");//but Exception rise here
SW.Write(textBox1.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

The following code should generate an exception in Windows Vista do

   FIP.Demand();//Exception must rise here

Why not create?

My OS : Vista

A: 

You are checking code execute permissions, not actual file permissions.

leppie
So what should I do?
ehsan_d18
@ehsan_d18: First steps would be to research how they are different, once you understand that, it should be clear.
leppie