Using Code Access Security (CAS) to programatically refuse writing to a drive - Shalvin

Please support our C# advertiser: Intel Parallel Studio Home
Shalvin Shalvin is offline Offline Feb 26th, 2008, 6:05 am |
0
CAS is the programatically means by which you secure the resouce of a system like file system, printer, registry, etc. in contrast to Role Base Security (RBS)
Quick reply to this message  
C# Syntax
  1. using System.Security.Permissions;
  2. using System.Security;
  3. using System.IO;
  4.  
  5. [assembly: FileIOPermissionAttribute(SecurityAction.RequestRefuse , Write="d:\\")]
  6. namespace WindowsFormsApplication1
  7. {
  8. public partial class Form1 : Form
  9. {
  10. StreamWriter sw;
  11. private void button1_Click(object sender, EventArgs e)
  12. {
  13. sw = File.CreateText("d:\\Shalvin.txt");
  14. sw.WriteLine("Hello");
  15. sw.Close();
  16. }

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC