1

ファイルのプロパティ ウィンドウを表示するコードがありました。

ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = @"C:\Users\nyongrand\Desktop\Internet Download Manager.lnk";
psi.Verb = "properties";
Process process = Process.Start(psi);
process.WaitForExit(); //This give me exception, Object reference not set to an instance of an object.

私が望むのは、ウィンドウのプロパティが閉じられるまで待機することです。コードが閉じられた場合、プロパティウィンドウも閉じられるため、コードがプロパティウィンドウが閉じられるのを待つことができるか、コードが終了できるかの間の解決策が必要ですプロパティウィンドウを閉じずに。

4

2 に答える 2

0

交換してみる

Process process = Process.Start(psi);

Process process = new Process();

if(process.Start(psi))
{
    process.WaitForExit();
}
else
{
    //Do something here to handle your process failing to start
}

コードで直面する問題は、Process.Start()がブール値を返すことです。Process オブジェクトのファクトリではありません。

于 2013-05-07T23:53:01.480 に答える