示例#1
0
        private void filePath_DragDrop(object sender, DragEventArgs e)
        {
            //GetValue(0) 为第1个文件全路径
            //DataFormats 数据的格式,下有多个静态属性都为string型,除FileDrop格式外还有Bitmap,Text,WaveAudio等格式
            string path = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();

            filePath.Text = path;
            //this.filePath.Cursor = System.Windows.Forms.Cursors.IBeam; //还原鼠标形状


            if (filePath.Text != "" && filePath.Text != "请先选择一个XML配置文件!")
            {
                if (DbType == "Oracle")
                {
                    formxml              = new FormXMLExecute("*Oracle*", filePath.Text);
                    formxml.FormClosing += new FormClosingEventHandler(this.FromXMLExecute_FormClosing);
                    formxml.Show();
                }
                else if (DbType == "SQLServer")
                {
                    formxml              = new FormXMLExecute(DbName, filePath.Text);
                    formxml.FormClosing += new FormClosingEventHandler(this.FromXMLExecute_FormClosing);
                    formxml.Show();
                }
            }
            else
            {
                filePath.Text = "请先选择一个XML配置文件!";
            }
        }
示例#2
0
        private void chooseFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = "c:\\";//注意这里写路径时要用c:\\而不是c:\
            openFileDialog.Filter           = "(xml文件)|*.xml";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.FilterIndex      = 1;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                filePath.Text = openFileDialog.FileName;
            }
            else
            {
                filePath.Text = "";
            }

            if (filePath.Text != "" && filePath.Text != "请先选择一个XML配置文件!")
            {
                if (DbType == "Oracle")
                {
                    formxml              = new FormXMLExecute("*Oracle*", filePath.Text);
                    formxml.FormClosing += new FormClosingEventHandler(this.FromXMLExecute_FormClosing);
                    formxml.Show();
                }
                else if (DbType == "SQLServer")
                {
                    formxml              = new FormXMLExecute(DbName, filePath.Text);
                    formxml.FormClosing += new FormClosingEventHandler(this.FromXMLExecute_FormClosing);
                    formxml.Show();
                }
            }
            else
            {
                filePath.Text = "请先选择一个XML配置文件!";
            }
        }