IV: Use C # to call ConvertDoc2PDF.js script Create a new C # the WINDOWS application, add a button button1 Add a function, function names StartConvertPDF public void StartConvertPDF () ( Process proc = new Process (); proc.StartInfo.FileName = "cmd.exe"; proc.StartInfo.WorkingDirectory = @ "c: \"; proc.StartInfo.CreateNoWindow = true; proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardInput = true;//input redirection
proc.Start (); proc.StandardInput.WriteLine (@ "cscript//nologo c: \ ConvertDoc2PDF.js c: \ test.doc c: \"); proc.StandardInput.WriteLine ( "exit"); proc.WaitForExit (); )
then CLICK the button to add the incident to call the code thread private void button1_Click (object sender, System.EventArgs e) ( //Definition of line procedures Thread thConvert = new Thread (new ThreadStart (StartConvertData)); thConvert.Start (); )
Note: In testing the above C # program, it is important to add the following namespace using System.Diagnostics; using System.Threading;
|