本文介绍了在其他PC上运行.exe时获取文件未找到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在c#中创建了一个应用程序,它在cmd中执行文件并将输出存储在文本文件中然后显示它。这在一台PC上运行良好,但如果我把它带到其他PC,它会给我找不到文件错误请帮帮我这个



我尝试过:



I have created a application in c# which execute file in cmd and store the output in text file and then displays it.This runs well on one PC ,but if i take it to some other PC it gives me file not found error .Please help me out in this

What I have tried:

strCmdText = "/C"+textBox1.Text + " --gtest_list_tests>>PathForGtest.txt";
           System.Diagnostics.Process.Start("CMD.exe", strCmdText);




string h=Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"PathForGtest.txt");

            System.IO.StreamReader file = new System.IO.StreamReader (h);


            while ((fileLine = file.ReadLine()) != null)
            {
                if ((fileLine.EndsWith(".")))
                {
                    buffer = fileLine;
                    continue;
                }
                else
                {
                    line = fileLine.Trim();
                    propertyNode = propertyNode + 1;
                }
                propertyName = buffer + line;

推荐答案


这篇关于在其他PC上运行.exe时获取文件未找到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 23:52
查看更多