BrowserSelector.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using Azylee.Core.DataUtils.StringUtils;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. namespace Azylee.Core.WindowsUtils.BrowserUtils
  8. {
  9. /// <summary>
  10. /// 浏览器选择器
  11. /// </summary>
  12. public class BrowserSelector
  13. {
  14. /// <summary>
  15. /// 现代浏览器
  16. /// </summary>
  17. /// <param name="browser"></param>
  18. /// <returns></returns>
  19. public static bool ModernBrowser(out string browser)
  20. {
  21. browser = "";
  22. string chrome = @"C:\Program Files\Google\Chrome\Application\chrome.exe";
  23. string chrome_86 = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
  24. string chrome_app = @"C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe";
  25. string firefox = @"C:\Program Files\Mozilla Firefox\firefox.exe";
  26. string firefox_86 = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
  27. if (File.Exists(chrome)) browser = chrome;
  28. else if (File.Exists(chrome_86)) browser = chrome_86;
  29. else if (File.Exists(chrome_app)) browser = chrome_app;
  30. else if (File.Exists(firefox)) browser = firefox;
  31. else if (File.Exists(firefox_86)) browser = firefox_86;
  32. if (Str.Ok(browser)) return true;
  33. return false;
  34. }
  35. /// <summary>
  36. /// 时期时代浏览器IE
  37. /// </summary>
  38. /// <param name="browser"></param>
  39. /// <returns></returns>
  40. public static bool StoneAgeIE(out string browser)
  41. {
  42. browser = "";
  43. string ie = @"C:\Program Files\internet explorer\iexplore.exe";
  44. string ie_86 = @"C:\Program Files (x86)\Internet Explorer\iexplore.exe";
  45. if (File.Exists(ie)) browser = ie;
  46. else if (File.Exists(ie_86)) browser = ie_86;
  47. if (Str.Ok(browser)) return true;
  48. return false;
  49. }
  50. }
  51. }