Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string[] strs       = KanngHelper.ReadAllLines();
            bool     rlb        = false;
            string   errorFiles = "";

            if (strs != null)
            {
                foreach (string str in strs)
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            //跳过注释
                            if (!str.StartsWith("#"))
                            {
                                rlb |= true;
                                Process.Start(str);
                                Thread.Sleep(Limetime);

                                //if (File.Exists(str) || Directory.Exists(str))
                                //{

                                //}
                                ////else if (Directory.Exists(str))
                                ////{
                                ////    rlb |= true;
                                ////    Process.Start("Explorer.exe", str);
                                ////    Thread.Sleep(Limetime);
                                ////}
                                //else
                                //{
                                //    errorFiles += str + "\r\n";
                                //}
                            }
                        }
                    }
                    catch (Exception ex)//容错处理
                    {
                        errorFiles += str + "\r\n";
                    }
                }
            }

            if (!rlb)
            {
                MessageBox.Show("没有需要启动的文件,您可以拖动文件到界面来添加文件!");
            }
            if (errorFiles.Length > 0)
            {
                MessageBox.Show("没有启动成功的文件:\r\n" + errorFiles);
            }
        }
Example #2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            DialogResult dr  = MessageBox.Show("确定要启动吗?", "确认", MessageBoxButtons.YesNo);
            bool         rlb = false;

            if (dr == DialogResult.Yes)
            {
                string[] strs       = KanngHelper.ReadAllLines();
                string   errorFiles = "";
                if (strs != null)
                {
                    foreach (string str in strs)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            //跳过注释
                            if (!str.StartsWith("#"))
                            {
                                if (File.Exists(str))
                                {
                                    rlb |= true;
                                    Process.Start(str);
                                }
                                else if (Directory.Exists(str))
                                {
                                    rlb |= true;
                                    Process.Start("Explorer.exe", str);
                                }
                                else
                                {
                                    errorFiles += str + "\r\n";
                                }
                            }
                        }
                        Thread.Sleep(200);
                    }
                }

                if (!rlb)
                {
                    MessageBox.Show("没有需要启动的文件,您可以拖动文件到界面来添加文件!");
                }
                if (errorFiles.Length > 0)
                {
                    MessageBox.Show("没有启动成功的文件:\r\n" + errorFiles);
                }
            }


            beginMove        = true;
            currentXPosition = MousePosition.X;
            currentYPosition = MousePosition.Y;
        }