[求助]类的权限控制

wyhao 2008-06-23 09:57:56
如何控制引用的一个外部类的权限?比如禁止操作文件访问网络之类的?
...全文
87 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wyhao 2008-06-23
  • 打赏
  • 举报
回复
了解~~~~~~~~~~~~~~~谢谢
gomoku 2008-06-23
  • 打赏
  • 举报
回复

using System.Security;
using System.Security.Permissions;


[FileIOPermission(SecurityAction.Deny, All="C:\\")]
void FirstMetho()
{
// all read write upon files in c: drive will be denied
// ...
classInTheDll.ReadAllText("c:\\temp\\ufo.cs"); // denied
// ...
}

void SecondMethod()
{
WebPermission myWebPermission =
new WebPermission(NetworkAccess.Connect,"http://abc.com");

myWebPermission.Deny();

// access to abc.com will be denied
//
classInTheDll.SomeFunction();

CodeAccessPermission.RevertDeny();
}


wyhao 2008-06-23
  • 打赏
  • 举报
回复
没人回?自己顶下,别沉的没了

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧