WPFウィンドウでホストされているWFコントロールを持つアプリケーションがあり、プロジェクトでいくつかのレコードおよび再生アクションを処理しています。私は再生を実行中に以下の例外を受け取ります。mscorlib.dllで 'System.ComponentModel.Win32Exception'型の未処理の例外が発生しました
私はこれについて検索し、またこれを試してみました私たちはprocess.Iへのファイルの完全なパスを提供する必要があるいくつかの提案を見てきました
ファイルが指定された見つけるが、それでも私は」することはできませんシステムこの例外が発生しました。
これを解決する方法を教えてもらえますか?
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();
窓が将来的にそれを使用しないでくださいあなたは、変数var targetPath
UTをdefinre pathes
\
を使用するので、あなたは、バックスラッシュp.StartInfo.FileName = mainPath.Replace("\\", "/");
を置き換えるべきではないおかげで、
サイドノート:なぜあなたは 'Path.Combine'を使用していませんか?これらのスラッシュの前と後のすべての必要はありません。あなたの人生を楽にします。 – Blacktempel