

1

2

3

4

读取ini


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



38

39

40

41

42

43



44

45

46

47

48

49

50

51

52

53

54

55



对ini文件进行操作
1


2

3



4

5

6

7

8



9

10

11

12

13

14

15

写日志函数
1write log#region write log
2 private static void WriteLog(string LogContent)
3
{
4 //get path
5 //File.Exists(System.Windows.Forms.Application.StartupPath + "log\\tif.ini"))
6 //string strPath = System.Configuration.ConfigurationSettings.AppSettings.Get("LogPath");
7 string strPath = System.Windows.Forms.Application.StartupPath + "\\log";
8 if (strPath == "")
9 return;
10
11 if (!Directory.Exists(strPath))
12
{
13 //create path
14 Directory.CreateDirectory(strPath);
15 }
16
17 string fileName = DateTime.Now.ToString("yyyyMMdd") + ".log";
18 strPath = strPath + "\\" + fileName;
19
20 string context = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " ----> " + LogContent;
21 if (File.Exists(strPath))
22
{
23 StreamWriter log_sw = File.AppendText(strPath);
24 log_sw.WriteLine(context);
25 log_sw.Close();
26 }
27 else
28
{
29 StreamWriter log_sw = File.CreateText(strPath);
30 log_sw.WriteLine(context);
31 log_sw.Close();
32 }
33 }
34 #endregion