Web api搜索错误路径中的库文件

本文关键字:文件 路径 api 搜索 错误 Web | 更新日期: 2023-09-27 18:04:30

我正在使用外部库NTextCat进行文本语言识别,它加载保存语言定义的外部.txt文件。文件在运行时加载。我已经在几个项目中成功地使用了这个库:净,ASP。. NET MVC和WinForms.

下面是构造函数在加载文件时的样子,我使用空构造函数:

 var languageIdentifier = new LanguageIdentifier(); // Empty constructor uses default 'LM fodler
 var languageIdentifier = new LanguageIdentifier("path to files"); // Overload which takes different path to files

我已经把这个文件夹复制到解决方案中的每个项目,包括每个bin文件夹,没有运气。

得到如下异常:

Could not find a part of the path 'C:'Program Files (x86)'Common Files'Microsoft Shared'DevServer'10.0'LM''.A first chance exception of type 'System.AggregateException' occurred in mscorlib.dll 

为什么它一直在搜索那条路径?

Web api搜索错误路径中的库文件

我忘记了你必须在web上映射路径,所以:

  var path = Path.Combine(HttpRuntime.AppDomainAppPath, "LM");
  var languageIdentifier = new LanguageIdentifier(path);