获取微信聊天记录

添加包

using FlaUI.UIA3;

using Application = FlaUI.Core.Application;

界面

主要代码

其他代码

/// <summary>
        /// 判断两个集合是否相等
        /// </summary>
        /// <param name="list1"></param>
        /// <param name="list2"></param>
        /// <returns></returns>
        public bool IsListEquals(List<string> list1, List<string> list2)
        {
            
            if (list1.Count == list2.Count)
            {
                if (list1.SequenceEqual(list2))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 判断为该名字的文件是否存在  如果不存在则创建
        /// </summary>
        /// <param name="Name">名字</param>
        /// <returns>文件是否存在</returns>
        public static bool IsCreateFile(string Name)
        {

            if (!File.Exists(Name))
            {

                FileStream mystream = new FileStream(Name, FileMode.Create, FileAccess.Write);
                mystream.Close();
                return false;
            }
            else
            {
                return true;
            }
        }

        /// <summary>
        /// 返回当前路径文件的最后一句话
        /// </summary>
        /// <param name="Path"></param>
        /// <returns>最后一句话</returns>
        public static string GetLastMessage(string Path)
        {
            if (File.Exists(Path))
            {
                string strContent = File.ReadAllText(Path);
                if (strContent.Trim() == "")
                {
                    return null;
                }
                else
                {
                    strContent = strContent.Replace("
", "&");
                    string[] strList = strContent.Split(&);
                    string lastMessage = strList.Last();
                    return lastMessage;
                }
            }
            else
            {
                return null;
            }

        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            System.Environment.Exit(0);
        }
经验分享 程序员 微信小程序 职场和发展