Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在.NET 5.0中,对于捆绑的程序集,返回的值是空字符串_C#_Reflection_Blazor_Webassembly_.net 5 - Fatal编程技术网

C# 在.NET 5.0中,对于捆绑的程序集,返回的值是空字符串

C# 在.NET 5.0中,对于捆绑的程序集,返回的值是空字符串,c#,reflection,blazor,webassembly,.net-5,C#,Reflection,Blazor,Webassembly,.net 5,从.NET5开始,我的方法FileInfo\u dataRoot=newfileinfo(typeof(Program).Assembly.Location)返回一个空字符串 我可以使用什么替代方法获取文件的路径 using System.IO; namespace BlazorClient { public class PathUtilities { public static string GetPathFromBinFolder(string relativePath) {

从.NET5开始,我的方法FileInfo\u dataRoot=newfileinfo(typeof(Program).Assembly.Location)返回一个空字符串

我可以使用什么替代方法获取文件的路径

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;
  }
}
}

为什么在blazor项目中需要这个?这是一个webassembly项目?为什么您认为您可以从浏览器中访问硬盘驱动器?我正在学习本教程,但在WebAssembly客户端中,它是一个机器学习应用程序。我需要同时读取型号和标签文件:您将无法从服务器的硬盘读取文件,当在用户浏览器中运行时,该文件将在客户启动应用程序时下载到客户机上,并且我的应用程序必须能够访问这些文件