本文整理汇总了C#中System.Security.Permissions.FileIOPermission.SetPathList方法的典型用法代码示例。如果您正苦于以下问题:C# FileIOPermission.SetPathList方法的具体用法?C# FileIOPermission.SetPathList怎么用?C# FileIOPermission.SetPathList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Permissions.FileIOPermission
的用法示例。
在下文中一共展示了FileIOPermission.SetPathList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FlatFileListenerWillFallbackIfNotPriviledgesToWrite
public void FlatFileListenerWillFallbackIfNotPriviledgesToWrite()
{
string fileName = @"trace.log";
string fullPath = String.Format(@"{0}\{1}", Directory.GetCurrentDirectory(), fileName);
File.Delete(fileName);
FileIOPermission fileIOPerm1 = new FileIOPermission(PermissionState.None);
fileIOPerm1.SetPathList(FileIOPermissionAccess.Read, fullPath);
fileIOPerm1.PermitOnly();
try
{
FlatFileTraceListener listener = new FlatFileTraceListener(fileName, "---header---", "***footer***",
new TextFormatter("DUMMY{newline}DUMMY"));
// need to go through the source to get a TraceEventCache
LogSource source = new LogSource("notfromconfig", new[] { listener }, SourceLevels.All);
source.TraceData(TraceEventType.Error, 0,
new LogEntry("message", "cat1", 0, 0, TraceEventType.Error, "title", null));
listener.Dispose();
}
catch (SecurityException)
{
FileIOPermission.RevertAll();
throw;
}
}
示例2: CreatePermission
public override IPermission CreatePermission()
{
if (base.m_unrestricted)
{
return new FileIOPermission(PermissionState.Unrestricted);
}
FileIOPermission permission = new FileIOPermission(PermissionState.None);
if (this.m_read != null)
{
permission.SetPathList(FileIOPermissionAccess.Read, this.m_read);
}
if (this.m_write != null)
{
permission.SetPathList(FileIOPermissionAccess.Write, this.m_write);
}
if (this.m_append != null)
{
permission.SetPathList(FileIOPermissionAccess.Append, this.m_append);
}
if (this.m_pathDiscovery != null)
{
permission.SetPathList(FileIOPermissionAccess.PathDiscovery, this.m_pathDiscovery);
}
if (this.m_viewAccess != null)
{
permission.SetPathList(FileIOPermissionAccess.NoAccess, AccessControlActions.View, new string[] { this.m_viewAccess }, false);
}
if (this.m_changeAccess != null)
{
permission.SetPathList(FileIOPermissionAccess.NoAccess, AccessControlActions.Change, new string[] { this.m_changeAccess }, false);
}
permission.AllFiles = this.m_allFiles;
permission.AllLocalFiles = this.m_allLocalFiles;
return permission;
}
示例3: CreatePermission
public override IPermission CreatePermission()
{
if (m_unrestricted)
{
return new FileIOPermission(PermissionState.Unrestricted);
}
else
{
FileIOPermission perm = new FileIOPermission(PermissionState.None);
if (m_read != null)
perm.SetPathList( FileIOPermissionAccess.Read, m_read );
if (m_write != null)
perm.SetPathList( FileIOPermissionAccess.Write, m_write );
if (m_append != null)
perm.SetPathList( FileIOPermissionAccess.Append, m_append );
if (m_pathDiscovery != null)
perm.SetPathList( FileIOPermissionAccess.PathDiscovery, m_pathDiscovery );
#if FEATURE_MACL
if (m_viewAccess != null)
perm.SetPathList( FileIOPermissionAccess.NoAccess, AccessControlActions.View, new String[] { m_viewAccess }, false );
if (m_changeAccess != null)
perm.SetPathList( FileIOPermissionAccess.NoAccess, AccessControlActions.Change, new String[] { m_changeAccess }, false );
#endif
perm.AllFiles = m_allFiles;
perm.AllLocalFiles = m_allLocalFiles;
return perm;
}
}
示例4: CreatePermission
/// <include file='doc\PermissionAttributes.uex' path='docs/doc[@for="FileIOPermissionAttribute.CreatePermission"]/*' />
public override IPermission CreatePermission()
{
if (m_unrestricted)
{
return new FileIOPermission(PermissionState.Unrestricted);
}
else
{
FileIOPermission perm = new FileIOPermission(PermissionState.None);
if (m_read != null)
perm.SetPathList( FileIOPermissionAccess.Read, m_read );
if (m_write != null)
perm.SetPathList( FileIOPermissionAccess.Write, m_write );
if (m_append != null)
perm.SetPathList( FileIOPermissionAccess.Append, m_append );
if (m_pathDiscovery != null)
perm.SetPathList( FileIOPermissionAccess.PathDiscovery, m_pathDiscovery );
return perm;
}
}