schangxiang@126.com
2025-09-09 3d8966ba2c81e7e0365c8b123e861d18ee4f94f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
 
namespace siemensSapService.aspEntity
{
  public static  class writeTxt
    {
      public static Mutex mutex = new Mutex();
      public static void writeInfo(string pathName, string info)
      {
 
          if (mutex.WaitOne())
          {
              try
              {
                  string logName = pathName;
                  string strEX =info;
               
                  string path = @"D:\siemensSPA\" + logName +DateTime.Now.ToString("yy-MM-dd-HH-mm-ss-ffff")+".txt";
                  if (!Directory.Exists(Path.GetDirectoryName(path))) Directory.CreateDirectory(Path.GetDirectoryName(path));
                  if (!File.Exists(path)) File.WriteAllText(path, string.Empty);
                
                      File.WriteAllText(path, strEX);
                  
              }
              finally { mutex.ReleaseMutex(); }
 
          }
      
      }
    }
}