Monday, January 5, 2009

Print a file without open it but this code work only when we select websete as a filesystem :(

//this code alow print a document without open it. and this code allow pdf / txt/ //doc etc. but works only on filesystem website
/*System.Diagnostics.ProcessStartInfo PrintingProcess = new System.Diagnostics.ProcessStartInfo();
PrintingProcess.Verb = "print";
PrintingProcess.WindowStyle = ProcessWindowStyle.Hidden;
PrintingProcess.FileName = "c:/M.txt";//path for the file
PrintingProcess.UseShellExecute = true;
System.Diagnostics.Process.Start(PrintingProcess); */


The following code automaticaly close its print window un comment last three lines

Process PrintingProcess = new Process();
PrintingProcess.StartInfo.CreateNoWindow = false;
PrintingProcess.StartInfo.Verb = "print";
PrintingProcess.StartInfo.FileName = @"C:\m.txt";
PrintingProcess.Start();
//PrintingProcess.WaitForExit(10000);
//PrintingProcess.CloseMainWindow();
//PrintingProcess.Close();

Thanks
HelponDesk Team

No comments: