diff --git a/README.md b/README.md index f62ac6f..8f108f2 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,11 @@ The repository can also be added to a project by setting the `NuGet.Config` file #### `DirectoryInfo? GetDirectory(this Assembly? assembly)` -Gets a directory representing the assembly's `Location` property or null. +Gets a directory containing the assembly directory. + +#### `FileInfo? GetFile(this Assembly? assembly)` + +Gets a file representing the assembly's `Location` property or null. ### DirectoryInfo Extensions diff --git a/src/MfGames.IO/Extensions/AssemblyExtensions.cs b/src/MfGames.IO/Extensions/AssemblyExtensions.cs index 70e5a41..afe1ce7 100644 --- a/src/MfGames.IO/Extensions/AssemblyExtensions.cs +++ b/src/MfGames.IO/Extensions/AssemblyExtensions.cs @@ -14,10 +14,20 @@ namespace MfGames.IO.Extensions /// The assembly to get the directory. /// The directory or null if the assembly or location is null. public static DirectoryInfo? GetDirectory(this Assembly? assembly) + { + return assembly.GetFile()?.Directory; + } + + /// + /// Gets the file for a given assembly. + /// + /// The assembly to get the directory. + /// The directory or null if the assembly or location is null. + public static FileInfo? GetFile(this Assembly? assembly) { return assembly?.Location == null ? null - : new DirectoryInfo(assembly.Location); + : new FileInfo(assembly.Location); } } }