FileVersionInfo
can be easily found on NuGet, it's been located in
System.Diagnostics
namespace from the beginning, so you need just to install the package:
Install-Package System.Diagnostics.FileVersionInfo
and use this class as usual, getting the file info from some IFileProvider
, for example, PhysicalFileProvider
:
using System.Diagnostics;
var provider = new PhysicalFileProvider(applicationRoot);
// the applicationRoot contents
var contents = provider.GetDirectoryContents("");
// a file under applicationRoot
var fileInfo = provider.GetFileInfo("wwwroot/js/site.js");
// version information
var myFileVersionInfo = FileVersionInfo.GetVersionInfo(fileInfo.PhysicalPath);
// myFileVersionInfo.ProductVersion is available here
For Author
information you should use FileSecurity
class, which is located in System.Security.AccessControl
namespace, with type System.Security.Principal.NTAccount
:
Install-Package System.Security.AccessControl
Install-Package System.Security.Principal
after that usage is similar:
using System.Security.AccessControl;
using System.Security.Principal;
var fileSecurity = new FileSecurity(fileInfo.PhysicalPath, AccessControlSections.All);
// fileSecurity.GetOwner(typeof(NTAccount)) is available here
General rule right now is to google the full qualified name for a class and add core
or nuget
to it, so you'll definitely get needed file with it's new location.