Form1.cs
上传用户:lxycoco
上传日期:2022-07-21
资源大小:38457k
文件大小:2k
源码类别:

C#编程

开发平台:

Others

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7. using System.Security.Permissions;
  8. namespace DemandingPermissions
  9. {
  10. /// <summary>
  11. /// Summary description for Form1.
  12. /// </summary>
  13. public class Form1 : System.Windows.Forms.Form
  14. {
  15. private System.Windows.Forms.Button button1;
  16. /// <summary>
  17. /// Required designer variable.
  18. /// </summary>
  19. private System.ComponentModel.Container components = null;
  20. public Form1()
  21. {
  22. //
  23. // Required for Windows Form Designer support
  24. //
  25. InitializeComponent();
  26. // try
  27. // {
  28. FileIOPermission fileioperm = new
  29. FileIOPermission(FileIOPermissionAccess.AllAccess,@"c:");
  30. fileioperm.Demand();
  31. // }
  32. // catch
  33. // {
  34. // button1.Enabled = false;
  35. // }
  36. }
  37. /// <summary>
  38. /// Clean up any resources being used.
  39. /// </summary>
  40. protected override void Dispose( bool disposing )
  41. {
  42. if( disposing )
  43. {
  44. if (components != null) 
  45. {
  46. components.Dispose();
  47. }
  48. }
  49. base.Dispose( disposing );
  50. }
  51. #region Windows Form Designer generated code
  52. /// <summary>
  53. /// Required method for Designer support - do not modify
  54. /// the contents of this method with the code editor.
  55. /// </summary>
  56. private void InitializeComponent()
  57. {
  58. this.button1 = new System.Windows.Forms.Button();
  59. this.SuspendLayout();
  60. // 
  61. // button1
  62. // 
  63. this.button1.Location = new System.Drawing.Point(24, 24);
  64. this.button1.Name = "button1";
  65. this.button1.Size = new System.Drawing.Size(200, 23);
  66. this.button1.TabIndex = 0;
  67. this.button1.Text = "Button Requires FileIOPermission ";
  68. // 
  69. // Form1
  70. // 
  71. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  72. this.ClientSize = new System.Drawing.Size(272, 77);
  73. this.Controls.Add(this.button1);
  74. this.Name = "Form1";
  75. this.Text = "Form1";
  76. this.ResumeLayout(false);
  77. }
  78. #endregion
  79. /// <summary>
  80. /// The main entry point for the application.
  81. /// </summary>
  82. [STAThread]
  83. static void Main() 
  84. {
  85. Application.Run(new Form1());
  86. }
  87. }
  88. }