コード例 #1
0
        private void btnOpenPath_Click(object sender, EventArgs e)
        {
            if (radFileMode.Checked)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.InitialDirectory = CachePathDAL.GetWorkSpacePath();
                if (!String.IsNullOrEmpty(this.tbFilePath.Text))
                {
                    try
                    {
                        string floder = Path.GetDirectoryName(this.tbFilePath.Text);
                        if (Directory.Exists(floder))
                        {
                            openFileDialog.InitialDirectory = floder;
                        }
                    }
                    catch
                    {
                    }
                }

                openFileDialog.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*";
                if (openFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    this.tbFilePath.Text = openFileDialog.FileName;
                }
            }

            if (radFloderMode.Checked)
            {
                FolderBrowserDialog openFloderDialog = new FolderBrowserDialog();
                openFloderDialog.SelectedPath = CachePathDAL.GetWorkSpacePath();
                if (!String.IsNullOrEmpty(this.tbFilePath.Text))
                {
                    try
                    {
                        string floder = Path.GetDirectoryName(this.tbFilePath.Text);
                        if (Directory.Exists(floder))
                        {
                            openFloderDialog.SelectedPath = floder;
                        }
                    }
                    catch
                    {
                    }
                }
                if (openFloderDialog.ShowDialog() == DialogResult.OK)
                {
                    this.tbFilePath.Text = openFloderDialog.SelectedPath;
                }
            }

            ReadForDebugEncoding();
        }
コード例 #2
0
        private void btnLoadDictionary_Click(object sender, EventArgs e)
        {
            string floder = Path.GetFullPath(String.Format(@"{0}\dict", CachePathDAL.GetWorkSpacePath()));

            if (!Directory.Exists(floder))
            {
                Directory.CreateDirectory(floder);
            }

            string filename1 = Path.GetFullPath(String.Format(@"{0}\dict\{1}", CachePathDAL.GetWorkSpacePath(), "CharBond.coll"));

            AppendText(String.Format("请稍候,正在加载文件:{0}", filename1));
            objCharBondColl = SerialLib.DeserializeBinary <MemoryBondColl <string> >(filename1);

            string filename2 = Path.GetFullPath(String.Format(@"{0}\dict\{1}", CachePathDAL.GetWorkSpacePath(), "KeyWord.coll"));

            AppendText(String.Format("请稍候,正在加载文件:{0}", filename2));
            objKeyWordColl = SerialLib.DeserializeBinary <MemoryItemColl <string> >(filename2);

            AppendText("字典集加载完毕!");
        }