智云3.0授权文件生成器新版
liusuyi
2026-08-07 0ae10765f86b83cd6d9f7db818266c62521800cd
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.IO;
 
namespace Authorization.Tools
{
    public class Common
    {
        static object o = new object();
        public static void SaveToLicense(string msg, string adress, string dir_name)
        {
            System.IO.FileStream FS = null;
            System.IO.StreamWriter SW = null;
            lock (o)
            {
                try
                {
                    string startupPath = AppDomain.CurrentDomain.BaseDirectory;
                    string datefolder = Path.Combine(startupPath, dir_name, adress, DateTime.Now.ToString("yyyy-MM-dd"));
                    if (!Directory.Exists(datefolder))
                    {
                        try
                        {
                            Directory.CreateDirectory(datefolder);
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }
                    string filepath = Path.Combine(startupPath, dir_name, adress, DateTime.Now.ToString("yyyy-MM-dd"), "license.cpy");
                    if (!File.Exists(filepath))
                    {
                        try
                        {
                            FS = File.Create(filepath);
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                        finally
                        {
                            FS.Close();
                            FS.Dispose();
                        }
                        FS = new System.IO.FileStream(filepath, System.IO.FileMode.Append, System.IO.FileAccess.Write);
                    }
                    else
                    {
                        FS = new System.IO.FileStream(filepath, System.IO.FileMode.Create, System.IO.FileAccess.Write);
                    }
 
                    SW = new System.IO.StreamWriter(FS);
                    SW.Write(msg);
                    SW.Flush();
                }
                catch
                {
                    throw;
                }
                finally
                {
                    if (SW != null)
                    {
                        SW.Close();
                        SW.Dispose();
                    }
                    if (FS != null)
                    {
                        FS.Close();
                        FS.Dispose();
                    }
                }
            }
        }
    }
}