CANoe软件需要加密或者过滤信息频繁发布的小工具

13 篇文章 0 订阅

一、设计这个小工具的原因

        由于公司软件发布频繁CANoe上位机,且上位机内部也有一些内部输入信息需要摆放在一起,如何每次复制出来然后删除加密的".can"或者删除你希望删除C++工程源码,都可以利用我这个方案,简单优化一些就可以。

        汽车行业提升工作效率,这个只是工具链一环,需要整体的工具链都是提升效率才可以达到很好的效果,这里只是提供一个思路方案罢了。

二、工具UI界面设计

1、选择需要打开发布的软件

2、选择需要输出发布软件存放的位置,输出文件名在打开文件之后还可以根据版本逻辑进行重新命名

3、编写过滤规则

4、输出文件

5、打开输出文件

三、工具具体实现代码逻辑

        #region 打开文件夹
        List<string> listFilePath;
        private void btInSelect_Click(object sender, EventArgs e)
        {
            textBoxResult.Text = "ing……";

            //textBoxInpath.Text = SelectFolder(@"D:\Work\00AA_CANoeUpperComputer");
            textBoxInpath.Text = SelectFolder(textBoxInpath_Default.Text);

            if (textBoxInpath.Text != null && textBoxInpath.Text != "")
            {
                textBox_OutFileName.Text = GetLastFolderName(textBoxInpath.Text);

                listFilePath = GetAllFolderContent(textBoxInpath.Text);
                listBoxListFiles.Items.Clear();

                if (listFilePath != null)
                {
                    foreach (var item in listFilePath)
                    {
                        listBoxListFiles.Items.Add(item);
                    }
                }
            }
        }

        public static string SelectFolder(string defaultFolderPath)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
            folderBrowserDialog.SelectedPath = defaultFolderPath;

            DialogResult result = folderBrowserDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                return folderBrowserDialog.SelectedPath;
            }
            else
            {
                return null;
            }
        }

        public static List<string> GetAllFolderContent(string folderPath)
        {
            List<string> folderContentList = new List<string>();

            if (Directory.Exists(folderPath))
            {
                AddFolderContent(folderPath, folderContentList);
            }
            else
            {
                return null;
            }

            return folderContentList.Count > 0 ? folderContentList : null;
        }

        private static void AddFolderContent(string folderPath, List<string> folderContentList)
        {
            string[] subDirectories = Directory.GetDirectories(folderPath);
            string[] files = Directory.GetFiles(folderPath);

            foreach (string subDir in subDirectories)
            {
                folderContentList.Add(subDir); // 添加完整文件夹路径
                AddFolderContent(subDir, folderContentList); // 递归调用,获取文件夹内部内容
            }

            foreach (string file in files)
            {
                folderContentList.Add(file); // 添加完整文件路径
            }
        }

        public static string GetLastFolderName(string filePath)
        {
            string lastFolderName = new DirectoryInfo(filePath).Name;
            return lastFolderName;
        }

        public string GetFolderPath()
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
            DialogResult result = folderBrowserDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                return folderBrowserDialog.SelectedPath;
            }
            else
            {
                MessageBox.Show("未选择文件夹!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }
        }

        private void btOutSelect_Click(object sender, EventArgs e)
        {
            textBoxOutpath.Text = GetFolderPath();
        }
        #endregion

        #region 发布文件
        private void btOutFiles_Click(object sender, EventArgs e)
        {
            if (listFilePath != null)
            {
                listBoxOut.Items.Clear();

                List<string> FilterFiless = FilterFiles02(listFilePath, tB_f_01.Text, tB_f_02.Text, tB_f_03.Text, tB_f_04.Text);
                foreach (var item in FilterFiless)
                {
                    listBoxOut.Items.Add(item);
                }

                CopyFiles02(FilterFiless, textBoxOutpath.Text + "\\" + textBox_OutFileName.Text, textBoxInpath.Text);
            }

            textBoxResult.Text = "PASS";
        }
     
        private void btOpenFiles_Click(object sender, EventArgs e)
        {

        }
        #endregion 

四、留给你的建议

        希望对你有所借鉴,感谢您的支持~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值