当前位置: 首页>>代码示例>>C#>>正文


C# FileIOPermission.SetPathList方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:28,代码来源:FlatFileTraceListenerFixture.2008.cs

示例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;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:35,代码来源:FileIOPermissionAttribute.cs

示例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;
            }
        }
开发者ID:destinyclown,项目名称:coreclr,代码行数:29,代码来源:PermissionAttributes.cs

示例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;
     }
 }
开发者ID:ArildF,项目名称:masters,代码行数:21,代码来源:permissionattributes.cs


注:本文中的System.Security.Permissions.FileIOPermission.SetPathList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。