2010-05-07 5 views
0

Comment passer des arguments à un HtmlFile de C#?Comment passer des arguments à un fichier Html?

Comme: System.Diagnostics.Process.Start("Sample.html","Arguments");

Si j'exécute le code ci-dessus le fichier « sample.html » doit être ouvert et il devrait faire quelque chose avec les « arguments ».

Répondre

8
Process.Start(
    @"C:\Program Files\Internet Explorer\iexplore.exe", 
    "file:///c:/path/to/file/Sample.html?param1=value1" 
); 

MISE À JOUR:

Pour déterminer l'emplacement par défaut du navigateur:

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" 
     ); 
    } 
} 
+0

Vous obtiendrez +1 dès que vous déterminez le chemin du navigateur standard correct. ;-) –

+0

@Konrad, voir ma mise à jour :-) –

+0

Merci Darin Dimitrov – Pramodh

Questions connexes