Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
Obtaining file extended properties in .Net Core

I want to read extended properties like Product Version, Author, etc. from a file using .Net Core.

There were classes like FileVersionInfo that used to provide version information, Shell object to read more about file, etc.

Now, I don't find such classes any more. How do I read such info using .Net Core?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

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.

over 4 years ago · Santiago Trujillo Report

0

probably you can use File Info Provider into .net core..

IFileProvider provider = new PhysicalFileProvider(applicationRoot);
IDirectoryContents contents = provider.GetDirectoryContents(""); // the applicationRoot contents
IFileInfo fileInfo = provider.GetFileInfo("wwwroot/js/site.js"); // a file under applicationRoot

Iterate through fileInfo object.

See this for more information:

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/file-providers

Hope it helps.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!