系统找不到指定的文件 [英] system cannot find the file specified

查看:253
本文介绍了系统找不到指定的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好请帮帮我,我收到错误

她是我的代码



Hello Please Help me i am getting error
her is my code

public string RunExternalExe(string filename, string arguments = null)
       {
           var process = new Process();

           process.StartInfo.FileName = filename;
           if (!string.IsNullOrEmpty(arguments))
           {
               process.StartInfo.Arguments = arguments;
           }

           process.StartInfo.CreateNoWindow = true;
           process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
           process.StartInfo.UseShellExecute = false;

           process.StartInfo.RedirectStandardError = true;
           process.StartInfo.RedirectStandardOutput = true;
           var stdOutput = new StringBuilder();
           process.OutputDataReceived += (sender, args) => stdOutput.Append(args.Data);

           string stdError = null;
           try
           {
              // process.Start("rtmpdump.exe");
               System.Diagnostics.Process.Start("rtmpdump", filename);
              // Process.Start(filename);
               process.BeginOutputReadLine();
               stdError = process.StandardError.ReadToEnd();
               process.WaitForExit();
           }
           catch (Exception e)
           {
               throw new Exception("OS error while executing " + Format(filename, arguments) + ": " + e.Message, e);
           }

           if (process.ExitCode == 0 || process.ExitCode == 2)
           {
               string yes = "yes";

               return yes;
           }
           else
           {


               return "no";
           }
       }

       private static string Format(string filename, string arguments)
       {
           return "'" + filename +
               ((string.IsNullOrEmpty(arguments)) ? string.Empty : " " + arguments) +
               "'";
       }

推荐答案

解决了m问题





have solved m problem


string currentLocation = AppDomain.CurrentDomain.BaseDirectory;
           string[] s=  currentLocation.Split('b');
           string final = s[0] +"b"+ s[1] +"b"+ s[2];

          
         string rtmpDump = Path.Combine(final, "Tool\\Rtmpdump\\rtmpdump.exe");


Hi Lakhan ,



System.Diagnostics.Process.Start(rtmpdump,filename)中发生错误; line?

如果是这样的话那么你试图从路径访问的文件是无效的,因为错误本身是自我描述的.....



建议:通过资源管理器手动检查路径中的文件。

我认为c#代码不会不必要地责备你;-)



希望这会对你有所帮助。



问候,

RK
Hi Lakhan,

The error occurs in System.Diagnostics.Process.Start("rtmpdump", filename); line?
If it so then the file you are trying to access from the path is not valid as the error itself is self descriptive.....

Suggestion: Check for the file in the path manually through explorer.
I think c# code wont blame you unnecessarily ;-)

Hope this helps you a bit.

Regards,
RK


两件事:

1)检查rtmpdump是否已安装,可用,并且在系统路径上:打开命令提示符并键入rtmpdump并按Enter。它运行吗?我怀疑不是......

2)你为什么要顶一个Process实例,然后完全忽略它?
Two things:
1) check that "rtmpdump" is installed, available, and on the system path: open a command prompt and type "rtmpdump" and press ENTER. Does it run? I suspect not...
2) why do you crest a Process instance, and then totally ignore it?


这篇关于系统找不到指定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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