Guest User

Untitled

a guest
Nov 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. try
  2. {
  3. byte[] bytes = Convert.FromBase64String(content);
  4.  
  5. File.WriteAllBytes(path, bytes);
  6.  
  7. this.debug(adobePath);
  8. this.debug(path);
  9. var isLocked = true;
  10.  
  11. /*while (isLocked)
  12. {
  13. try{
  14. File.ReadAllBytes(path);
  15. isLocked = false;
  16. this.debug("FILE IS FREED");
  17. }
  18. catch(Exception)
  19. {
  20. this.debug("SLEEP");
  21. Thread.Sleep(50);
  22. }
  23. }*/
  24.  
  25. Process process = new Process();
  26.  
  27. process.StartInfo.UseShellExecute = false;
  28. process.StartInfo.FileName = adobePath;
  29. process.StartInfo.Arguments = string.Format("/t {0} "{1}"", path, printerName);
  30. process.StartInfo.CreateNoWindow = true;
  31. process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
  32.  
  33. process.Start();
  34. // Stops here without printing the file
  35.  
  36. process.WaitForExit();
  37.  
  38. if (!process.HasExited)
  39. {
  40. process.WaitForInputIdle();
  41. process.CloseMainWindow();
  42. process.Kill();
  43. }
  44.  
  45. this.debug("FINISH");
  46. }
  47. catch (Exception ex)
  48. {
  49. this.debug(ex.Message);
  50. }
  51. if (File.Exists(path))
  52. {
  53. File.Delete(path);
  54. }
Add Comment
Please, Sign In to add comment