frmBrowseOperateRule_Doc.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.IO;
  9. namespace Core.LgMes.Client.LgIntegrationQuery
  10. {
  11. public partial class frmBrowseOperateRule_Doc : Core.Mes.Client.Common.frmStyleBase
  12. {
  13. public string strUrl = "";
  14. //public string strFileType = "";
  15. //public byte[] fileBytes = new byte[1024];
  16. //public string strSafeFileName;
  17. public frmBrowseOperateRule_Doc()
  18. {
  19. InitializeComponent();
  20. }
  21. private void frmBrowseOperateRule_Doc_Load(object sender, EventArgs e)
  22. {
  23. //strSafeFileName = strUrl.Substring(strUrl.LastIndexOf(@"\") + 1);
  24. ////System.IO.Stream st =null ;
  25. ////st.(fileBytes, 0, 1024);
  26. //System.IO.FileStream fileStream = new FileStream(strSafeFileName, FileMode.Create);
  27. //fileStream.Seek(0, SeekOrigin.Begin);
  28. //fileStream.Write(fileBytes, 0, fileBytes.Length);
  29. //System.IO.MemoryStream userInput = new MemoryStream();
  30. //userInput.Position = 0;
  31. //userInput.WriteTo(fileStream);
  32. //fileStream.Close();
  33. //System.IO.Stream stream = new MemoryStream(fileBytes);
  34. //try
  35. //{
  36. // if (strFileType == "doc" || strFileType == "rtf")
  37. // {
  38. // richTextBox1.LoadFile(strUrl.Replace("doc", "rtf"), RichTextBoxStreamType.RichText);
  39. // //fileStream.Position = 0;
  40. // //richTextBox1.LoadFile(fileStream, RichTextBoxStreamType.PlainText);
  41. // }
  42. // else if (strFileType == "txt")
  43. // richTextBox1.LoadFile(strUrl, RichTextBoxStreamType.PlainText);
  44. //}
  45. //catch { }
  46. try
  47. {
  48. if (this.strUrl.Trim().Length == 0) return;
  49. if (File.Exists(strUrl))
  50. this.webBrowser1.Url = new Uri(strUrl);
  51. else
  52. this.webBrowser1.Navigate("about:blank");
  53. }
  54. catch (Exception ex)
  55. {
  56. this.webBrowser1.Navigate("about:blank");
  57. MessageBox.Show(ex.Message);
  58. }
  59. }
  60. private void frmBrowseOperateRule_Doc_FormClosed(object sender, FormClosedEventArgs e)
  61. {
  62. try
  63. {
  64. //if (strFileType == "doc" || strFileType == "rtf")
  65. //{
  66. // System.IO.File.Delete(@strUrl.Replace("doc", "rtf"));
  67. //}
  68. //else if (strFileType == "txt")
  69. // System.IO.File.Delete(@strUrl);
  70. this.webBrowser1.Navigate("about:blank");
  71. if (File.Exists(strUrl))
  72. File.Delete(strUrl);
  73. }
  74. catch { }
  75. finally
  76. {
  77. this.webBrowser1.Navigate("about:blank");
  78. if (File.Exists(strUrl))
  79. File.Delete(strUrl);
  80. }
  81. }
  82. }
  83. }