Beispiel #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     config = new CConfig();
     try
     {
         this.DictPath = ConfigurationManager.AppSettings["DictPath"];
         if (this.DictPath == null)
         {
             throw new Exception("找不到字典路径配置");
         }
         tssLblDctPath.Text = this.DictPath;
     }
     catch
     {
         /*string confFilePath = Assembly.GetEntryAssembly().Location;
          * Configuration conf = ConfigurationManager.OpenExeConfiguration(confFilePath);
          * AppSettingsSection ass = (AppSettingsSection)conf.GetSection("appSettings");
          * ass.Settings.Add("DictPath", ".\\Dicts\\");
          * conf.Save();*/
         config.setDictPath(".\\Dicts\\");
         tssLblDctPath.Text = ".\\Dicts\\";
     }
     lvResult.Columns.Clear();
     lvResult.Columns.Add("Status", 60);
     lvResult.Columns.Add("URL", lvResult.Width - 80);
     cnt  = 0;
     last = DateTime.MinValue;
     try
     {
         string[] dictFiles = CWebDirScan.LoadDicts(this.DictPath);
         if (dictFiles != null)
         {
             clbDicts.Items.AddRange(dictFiles);
         }
         else
         {
             MessageBox.Show(string.Format("在目录{0}下没有找到字典!", this.DictPath),
                             "错误",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Error
                             );
         }
         webScan = new CWebDirScan();
         webScan.OnScanResult += webScan_OnScanResult;
         webScan.OnFinished   += webScan_OnFinished;
     }
     catch
     {
     }
 }
Beispiel #2
0
        private void 修改字典路径ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            DialogResult        dr  = fbd.ShowDialog();

            if (dr == DialogResult.OK)
            {
                this.DictPath      = fbd.SelectedPath;
                tssLblDctPath.Text = this.DictPath;
                try
                {
                    config.setDictPath(this.DictPath);
                }
                catch (Exception err)
                {
                    MessageBox.Show("保存字典配置失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            try
            {
                string[] dictFiles = CWebDirScan.LoadDicts(this.DictPath);
                clbDicts.Items.Clear();
                if (dictFiles != null)
                {
                    clbDicts.Items.AddRange(dictFiles);
                }
                else
                {
                    MessageBox.Show(string.Format("在目录{0}下没有找到字典!", this.DictPath),
                                    "错误",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error
                                    );
                }
            }
            catch
            {
            }
        }