【问题标题】:file not found for a jar file -- even when I get the file name via Directory.getFiles()找不到 jar 文件的文件 - 即使我通过 Directory.getFiles() 获取文件名
【发布时间】:2013-09-09 15:00:57
【问题描述】:

我正在尝试使用 shell 命令运行一个 jar 文件,但我得到了一个找不到文件的异常。我发现这篇文章说要使用Directory.getFilesFile not found Exception.. But it's there

当我按照那篇文章中的建议进行操作时,我得到了一些非常奇怪的行为:

Dim files As List(Of String) = Directory.GetFiles("Path\Java").ToList //returns one file
Shell(files.First) //throws file not found exception

我可以通过path\java\java -jar myDriver.jar argumentOne在windows中使用命令行运行这个jar

发生了什么事?如何在 .NET 代码中运行这个 jar 文件?

【问题讨论】:

  • 可能是权限问题。
  • @leppie 所以我有权读取目录的内容但不能执行?
  • 可能是相对路径问题。 path/java 是否与您的 bin/exe 在同一路径中?
  • 不,抱歉,GetFiles 会抛出异常。我在想File.Exists

标签: .net windows vb.net


【解决方案1】:

问题可能是您的 shell 命令与运行命令不匹配。

Shell(PathToFile)

不等于:

Shell(String.Format("{0} {1} {2}", "C:\PATHTOJAVA",PathToFile,Argument) 

【讨论】:

    猜你喜欢
    • 2012-12-15
    • 2012-05-03
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-08
    • 1970-01-01
    相关资源
    最近更新 更多