System.Diagnostics.Process.Start问题"无法找到特定文件" [英] System.Diagnostics.Process.Start problem "Can not find specific file"

查看:126
本文介绍了System.Diagnostics.Process.Start问题"无法找到特定文件"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我启动下我的电脑上的代码是正常工作

When I launch following code on my computer it is works fine

string target = e.Link.LinkData as string;
target = System.IO.Directory.GetCurrentDirectory() + target;
System.Diagnostics.Process.Start(target);



目标 - 非绝对到文件路径。文件是存在的。明确虚拟机的异常
无法找到特定文件就产生了。

target - non-absolute path to file. Files is exists. on clear Virtual Machine exception "Can not find specific file" is produced.

有什么建议?

更新

我强调的是,我的电脑上工作正常。
为什么它不工作的另一台计算机

Any suggestions?
Update
I underline that on my computer works fine. Why it doesn't works on another computer

推荐答案

的第一件事我会做,尝试并获得对这条底线,就是验证失败时所报告的确切路径。

The first thing I would do, to try and get to the bottom of this, is to verify the exact path that is reported when it fails.

修改你的代码是这样的(注意,我转而使用路径。结合由另一个海报提及):

Amend your code to something like this (note I've switched to using Path.Combine as mentioned by another poster):

string target = e.Link.LinkData as string;
target = Path.Combine(System.IO.Directory.GetCurrentDirectory() + target);
var fileInfo = new FileInfo(target);
if (!fileInfo.Exists)
{
    throw new FileNotFoundException("The requested file was not found: " + fileInfo.FullName);
}
System.Diagnostics.Process.Start(target);

这是失败的系统上运行此。是完全合格的路径确实您所期望的它是?

Run this on the system that fails. Is the fully qualified path really what you expected it to be?

如果没有 - 你要的原因。

If no - you've got to the cause.

如果是,则开始调查之类的东西权限。是否执行此有权访问或执行该文件,或者是在文件夹的用户?

If yes, then start investigating things like permissions. Does the user executing this have permission to access or execute the file, or the folder it is in?

回来后的任何进展......

Post back any progress...

这篇关于System.Diagnostics.Process.Start问题"无法找到特定文件"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆