本文整理汇总了C#中System.Security.Permissions.FileIOPermission.FromXml方法的典型用法代码示例。如果您正苦于以下问题:C# FileIOPermission.FromXml方法的具体用法?C# FileIOPermission.FromXml怎么用?C# FileIOPermission.FromXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Permissions.FileIOPermission
的用法示例。
在下文中一共展示了FileIOPermission.FromXml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromXML
public void FromXML ()
{
p = new FileIOPermission(PermissionState.None);
SecurityElement esd = new SecurityElement("IPermission");
esd.AddAttribute("class", "FileIOPermission");
esd.AddAttribute("version", "1");
esd.AddAttribute("Unrestricted", "true");
p.FromXml(esd);
Assert.IsTrue(p.IsUnrestricted(), "Should get an unrestricted permission");
esd = new SecurityElement("IPermission");
esd.AddAttribute("class", "FileIOPermission");
esd.AddAttribute("version", "1");
// FIXME: Adjust to run on Mac OS's
if (Path.VolumeSeparatorChar == ':') {
esd.AddAttribute("Read", "c:\\temp;d:\\temp2");
esd.AddAttribute("Write", "c:\\temp;d:\\temp2;z:\\temp3");
}
else {
esd.AddAttribute("Read", "/temp;/usr/temp2");
esd.AddAttribute("Write", "/temp;/usr/temp2;/usr/bin/temp3");
}
p = new FileIOPermission(PermissionState.None);
p.FromXml(esd);
pathsInPermission = p.GetPathList(FileIOPermissionAccess.Read);
Assert.IsTrue(pathsInPermission.Length == 2, "Path list should have 2 for Read");
pathsInPermission = p.GetPathList(FileIOPermissionAccess.Write);
Assert.IsTrue(pathsInPermission.Length == 3, "Path list should have 2 for Write");
}