Csharp/C Sharp/Security/PermissionSet — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 15:31, 26 мая 2010
Writing secure code.
using System;
using System.Drawing;
using System.Collections;
using System.ruponentModel;
using System.Windows.Forms;
using System.Data;
using System.Security;
using System.IO;
using System.Security.Permissions;
public class MainClass {
public static void Main(){
PermissionSet ps = new PermissionSet(System.Security.Permissions.PermissionState.None);
ps.AddPermission(new FileIOPermission(FileIOPermissionAccess.Read |FileIOPermissionAccess.Write | FileIOPermissionAccess.Append,"c:\\temp\\temp.txt"));
ps.Deny();
//ps.Assert();
FileStream fs = new FileStream(@"c:\temp\temp.txt",FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter m_streamWriter = new StreamWriter(fs);
m_streamWriter.BaseStream.Seek(0, SeekOrigin.End);
m_streamWriter.Write("Test");
}
}