0
如何將參數傳遞給C#中的HtmlFile?如何將參數傳遞給HtmlFile?
像:System.Diagnostics.Process.Start("Sample.html","Arguments");
如果我執行上面的代碼「Sample.html」文件應該被打開,它應該做的「論據」的東西。
如何將參數傳遞給C#中的HtmlFile?如何將參數傳遞給HtmlFile?
像:System.Diagnostics.Process.Start("Sample.html","Arguments");
如果我執行上面的代碼「Sample.html」文件應該被打開,它應該做的「論據」的東西。
Process.Start(
@"C:\Program Files\Internet Explorer\iexplore.exe",
"file:///c:/path/to/file/Sample.html?param1=value1"
);
UPDATE:
找出默認瀏覽器的位置:
class Program
{
[DllImport("shell32.dll")]
public extern static int FindExecutable(
string forFile,
string directory,
StringBuilder result
);
static void Main(string[] args)
{
var browserLocation = new StringBuilder(1024);
// make sure you specify the correct path and the file actually exists
// or the FindExecutable will return an empty string.
FindExecutable(@"d:\work\html\index.htm", null, browserLocation);
Process.Start(
browserLocation.ToString(),
"file:///d:/work/html/index.htm?param1=value1"
);
}
}
即可立即獲得+1你確定正確的標準瀏覽器的路徑。 ;-) – 2010-05-07 11:03:29
@Konrad,請參閱我的更新:-) – 2010-05-07 11:11:35
感謝Darin Dimitrov – Pramodh 2010-05-07 11:25:30