Browse Source

记录打印进程文件路径修改

Hcsy 8 years ago
parent
commit
fe220fdb89
3 changed files with 8 additions and 6 deletions
  1. 4 3
      UAS-MES/Main.cs
  2. 2 1
      UAS-MES/Program.cs
  3. 2 2
      UAS-MES/PublicMethod/BaseUtil.cs

+ 4 - 3
UAS-MES/Main.cs

@@ -42,6 +42,7 @@ namespace UAS_MES
         Thread TestPrint;
 
         string sysdisc = Environment.GetEnvironmentVariable("windir").Substring(0, 1);
+        string lblpath = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":\Log\cacheInfo";
 
         public Main()
         {
@@ -82,7 +83,7 @@ namespace UAS_MES
         private void Main_Load(object sender, EventArgs e)
         {
             //杀死全部未关闭的打印进程
-            string[] lines = System.IO.File.ReadAllLines(Directory.GetCurrentDirectory() + @"\" + "lblprocess" + ".txt");
+            string[] lines = System.IO.File.ReadAllLines(lblpath + @"\" + "lblprocess" + ".txt");
             foreach (string line in lines)
             {
                 if (line != "")
@@ -103,12 +104,12 @@ namespace UAS_MES
                         catch (Exception)
                         {
                         }
-                        FileStream fs = new FileStream(Directory.GetCurrentDirectory() + @"\" + "lblprocess" + ".txt", FileMode.Open, FileAccess.Read);
+                        FileStream fs = new FileStream(lblpath + @"\" + "lblprocess" + ".txt", FileMode.Open, FileAccess.Read);
                         StreamReader sr = new StreamReader(fs);
                         String s = sr.ReadToEnd();
                         sr.Close();
                         fs.Close();
-                        FileStream fas = new FileStream(Directory.GetCurrentDirectory() + @"\" + "lblprocess" + ".txt", FileMode.Create, FileAccess.ReadWrite);
+                        FileStream fas = new FileStream(lblpath + @"\" + "lblprocess" + ".txt", FileMode.Create, FileAccess.ReadWrite);
                         StreamWriter sw = new StreamWriter(fas);
                         sw.Write(s.Replace(line+"\r\n",""));
                         sw.Flush();

+ 2 - 1
UAS-MES/Program.cs

@@ -35,6 +35,7 @@ namespace UAS_MES
                 Application.AddMessageFilter(g);
                 //启用异常记录日志的操作
                 string sysdisc = Environment.GetEnvironmentVariable("windir").Substring(0, 1);
+                string lblpath = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":\Log\cacheInfo";
                 //创建标签缓存的文件夹
                 if (!Directory.Exists(ftpOperater.DownLoadTo))
                     Directory.CreateDirectory(ftpOperater.DownLoadTo);
@@ -61,7 +62,7 @@ namespace UAS_MES
                     doc.Save(Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":\Log\cacheInfo\cacheInfo.xml");
                 }
                 //创建记录打印进程的文件
-                FileStream fas = new FileStream(Directory.GetCurrentDirectory() + @"\" + "lblprocess" + ".txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
+                FileStream fas = new FileStream(lblpath + @"\" + "lblprocess" + ".txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
                 fas.Close();
                 if (principal.IsInRole(WindowsBuiltInRole.Administrator))
                     Application.Run(new Login());

+ 2 - 2
UAS-MES/PublicMethod/BaseUtil.cs

@@ -990,8 +990,8 @@ namespace UAS_MES.PublicMethod
                 }
             }
             String str = SystemInf.ProcessesID + "|" + PID;
-            string sysdisc = Environment.GetEnvironmentVariable("windir").Substring(0, 1);
-            FileStream fs = new FileStream(Directory.GetCurrentDirectory() + @"\" + "lblprocess" + ".txt", FileMode.Append, FileAccess.Write);
+            string lblpath = Environment.GetEnvironmentVariable("windir").Substring(0, 1) + @":\Log\cacheInfo";
+            FileStream fs = new FileStream(lblpath + @"\" + "lblprocess" + ".txt", FileMode.Append, FileAccess.Write);
             StreamWriter sw = new StreamWriter(fs);
             sw.WriteLine(str, Encoding.UTF8);
             sw.Close();