【发布时间】:2017-11-29 05:51:29
【问题描述】:
我在 WPF 窗口中托管了一个带有 WF 控件的应用程序,并且我正在我的项目中进行一些记录和播放操作。播放时出现以下异常。
系统找不到指定的文件
我已经对此进行了搜索,并看到了一些建议,我们需要提供要处理的文件的完整路径。我也尝试过,但仍然遇到此异常。
请任何人告诉我如何解决这个问题?
var instance = testclass.GetControlForTest();
WindowsFormsHost host = new WindowsFormsHost();
host.Child = instance;
var testwindow = new TestWindow(testdata, testclass, false, (MainWindow)Application.Current.MainWindow, true);
testwindow.testSurface.Children.Add(host);
testwindow.Show();
await Task.Delay(1000);
Process p = new Process();
var mainPath = Directory.GetCurrentDirectory();
do
{
mainPath = Directory.GetParent(mainPath).FullName;
} while (Directory.GetParent(mainPath).Name != "WindowsForms_Testing");
var targetPath = mainPath + "\\exes\\" + "\\";
mainPath = Directory.GetParent(mainPath).FullName;
mainPath = mainPath + "\\TestStudio\\Syncfusion.TestVisualBase.WPF\\RecordAction\\RecordAction.WPF\\bin\\Debug\\RecordAction.WPF.exe";
p.StartInfo.FileName = mainPath.Replace("\\", "/");
p.StartInfo.Arguments = file; //("..//..//test.xml")
p.Start();
谢谢,
【问题讨论】:
-
附注:为什么不使用
Path.Combine?路径前后不需要所有这些斜线......让您的生活更轻松。