Code Access Security - Denying Read permission on C: drive
using System.Security.Permissions;
using System.IO;
[assembly:FileIOPermission(SecurityAction.RequestRefuse,Read="C:\\")]
namespace CASS
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
StreamReader sr = new StreamReader("C:\\boot.ini");
MessageBox.Show(sr.ReadToEnd());
sr.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
No comments:
Post a Comment