The Labs \ Source Viewer \ SSCLI \ System.ComponentModel \ IntSecurity

  1. //------------------------------------------------------------------------------
  2. // <copyright file="IntSecurity.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.ComponentModel
  16. {
  17.     using System;
  18.     using System.Security;
  19.     using System.Security.Permissions;
  20.    
  21.     [HostProtection(SharedState = true)]
  22.     static internal class IntSecurity
  23.     {
  24.         public static readonly CodeAccessPermission UnmanagedCode = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
  25.         public static readonly CodeAccessPermission FullReflection = new ReflectionPermission(PermissionState.Unrestricted);
  26.        
  27.         public static string UnsafeGetFullPath(string fileName)
  28.         {
  29.             string full = fileName;
  30.            
  31.             FileIOPermission fiop = new FileIOPermission(PermissionState.None);
  32.             fiop.AllFiles = FileIOPermissionAccess.PathDiscovery;
  33.             fiop.Assert();
  34.             try {
  35.                 full = System.IO.Path.GetFullPath(fileName);
  36.             }
  37.             finally {
  38.                 CodeAccessPermission.RevertAssert();
  39.             }
  40.             return full;
  41.         }
  42.     }
  43. }

Developer Fusion