2
我的项目没有找到肯定存在的文件。我正在使用斯坦福大学的NLP库,并且收到了我没有发现的异常,我开始调试。文件未找到
这里是我的测试代码:
String jarRoot = @"stanford-corenlp-full-2016-10-31\stanford-corenlp-full-2016-10-31\stanford-corenlp-3.7.0-models\edu\stanford\nlp\models\pos-tagger\english-left3words\";
foreach (String fName in Directory.GetFiles(jarRoot))
{
Console.WriteLine("File in jarRoot: " + fName);
Console.WriteLine("File exists? " + File.Exists(fName));
}
输出:
File in jarRoot: stanford-corenlp-full-2016-10-31\stanford-corenlp-full-2016-10-31\stanford-corenlp-3.7.0-models\edu\stanford\nlp\models\pos-tagger\english-left3words\english-left3words-distsim.tagger
File exists? False
File in jarRoot: stanford-corenlp-full-2016-10-31\stanford-corenlp-full-2016-10-31\stanford-corenlp-3.7.0-models\edu\stanford\nlp\models\pos-tagger\english-left3words\english-left3words-distsim.tagger.props
File exists? False
怎么能File.Exists()可能会被返回false?目录的
jar root不是正确的物理路径,请确保路径正确。 – 2017-06-16 07:54:11
@TAHASULTANTEMURI这是一个非常有效的路径,不确定你的意思。 – Rob
首先尝试打开运行命令并运行此路径,如果它是有效的将不会有错误。 – 2017-06-16 07:55:51