/// <summary> /// Open the named file asynchronously for reading. /// </summary> /// <exception cref="FileNotFoundException">Throws if the file is not found.</exception> /// <remarks> /// Unlike <see cref="TryOpenReadOnly"/> this function throws an exception if the file is missing. /// </remarks> public static StreamWithLength OpenReadOnly(this IAbsFileSystem fileSystem, AbsolutePath path, FileShare share) { var stream = fileSystem.TryOpenReadOnly(path, share); if (stream == null) { throw new FileNotFoundException($"The file '{path}' does not exist."); } return(stream.Value); }