internal static void ThrowIfInvalidPath(string[] paths) { foreach (string path in paths) { FileIOPermission.ThrowIfInvalidPath(path); } }
/// <summary>Adds access for the specified file or directory to the existing state of the permission.</summary> /// <param name="access">A bitwise combination of the <see cref="T:System.Security.Permissions.FileIOPermissionAccess" /> values. </param> /// <param name="path">The absolute path of a file or directory. </param> /// <exception cref="T:System.ArgumentException">The <paramref name="access" /> parameter is not a valid value of <see cref="T:System.Security.Permissions.FileIOPermissionAccess" />.-or- The <paramref name="path" /> parameter is not a valid string.-or- The <paramref name="path" /> parameter did not specify the absolute path to the file or directory. </exception> /// <exception cref="T:System.ArgumentNullException">The <paramref name="path" /> parameter is null. </exception> public void AddPathList(FileIOPermissionAccess access, string path) { if ((FileIOPermissionAccess.AllAccess & access) != access) { FileIOPermission.ThrowInvalidFlag(access, true); } FileIOPermission.ThrowIfInvalidPath(path); this.AddPathInternal(access, path); }
/// <summary>Sets the specified access to the specified files and directories, replacing the current state for the specified access with the new set of paths.</summary> /// <param name="access">A bitwise combination of the <see cref="T:System.Security.Permissions.FileIOPermissionAccess" /> values. </param> /// <param name="pathList">An array containing the absolute paths of the files and directories. </param> /// <exception cref="T:System.ArgumentException">The <paramref name="access" /> parameter is not a valid value of <see cref="T:System.Security.Permissions.FileIOPermissionAccess" />.-or- An entry in the <paramref name="pathList" /> parameter is not a valid string. </exception> public void SetPathList(FileIOPermissionAccess access, string[] pathList) { if ((FileIOPermissionAccess.AllAccess & access) != access) { FileIOPermission.ThrowInvalidFlag(access, true); } FileIOPermission.ThrowIfInvalidPath(pathList); this.Clear(access); foreach (string path in pathList) { this.AddPathInternal(access, path); } }