jeudi 15 avril 2021

In .NET 5.0 for bundled assemblies, the value returned is an empty string

Since .net 5, my method FileInfo _dataRoot = new FileInfo(typeof(Program).Assembly.Location); returns an empty string.

What alternative can I use to get the path to my file?

using System.IO;

namespace BlazorClient
{
public class PathUtilities
{
  public static string GetPathFromBinFolder(string relativePath)
  {
      FileInfo _dataRoot = new FileInfo(typeof(Program).Assembly.Location);
      string assemblyFolderPath = _dataRoot.Directory.FullName;
 
      string fullPath = Path.Combine(assemblyFolderPath, relativePath);
      return fullPath;
  }
}
}




Aucun commentaire:

Enregistrer un commentaire