【问题标题】:Microsoft.ml cannot find the csv file even though its in my file directoryMicrosoft.ml 找不到 csv 文件,即使它在我的文件目录中
【发布时间】:2021-11-14 18:07:40
【问题描述】:

我知道这看起来很愚蠢,但由于某种原因找不到文本文件。

var data = context.Data.LoadFromTextFile("./housing.csv", hasHeader: true, 分隔符:','); 每当我运行此代码时,vs 控制台都会出现此错误:

System.ArgumentOutOfRangeException: '文件或目录不存在于路径:./housing.csv'

【问题讨论】:

  • 它在 /debug 文件夹中吗?
  • 如果 VS 的文件属性较新,可能需要将其设置为复制

标签: c# ml.net


【解决方案1】:

应用程序工作目录可能不是您所期望的。

尝试添加:

string dir = System.IO.Directory.GetCurrentDirectory();
var data = context.Data.LoadFromTextFile(dir + "\\housing.csv", hasHeader: true, separatorChar: ',');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-08
    • 2011-11-20
    相关资源
    最近更新 更多