private static void DemandPermission(string codeBase, bool havePath, int demandFlag) { FileIOPermissionAccess pathDiscovery = FileIOPermissionAccess.PathDiscovery; switch (demandFlag) { case 1: pathDiscovery = FileIOPermissionAccess.Read; break; case 2: pathDiscovery = FileIOPermissionAccess.PathDiscovery | FileIOPermissionAccess.Read; break; case 3: CreateWebPermission(AssemblyName.EscapeCodeBase(codeBase)).Demand(); return; } if (!havePath) { codeBase = new URLString(codeBase, true).GetFileName(); } codeBase = Path.GetFullPathInternal(codeBase); new FileIOPermission(pathDiscovery, codeBase).Demand(); }