public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            this.openFile.Multiselect = true;
        }
        private void DeleteFile(string paramPath)
        {
            string Path = paramPath.Substring(paramPath.LastIndexOf("\\") + 1);
            if (System.IO.File.Exists(paramPath))
            {
                if (MessageBox.Show("Whether delete? \n" + Path + "\t", "Hint", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                {
                    return;
                }
                else
                {
                    File.Delete(paramPath);                    MessageBox.Show("The document deletes success!");
                }
            }
            else
            {
                MessageBox.Show("The document done not want to delete !");
            }
        }        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.openFile.ShowDialog() == DialogResult.OK)
            {
                string paramPath = this.openFile.FileName;
                this.txtShow.Text = paramPath;
                this.DeleteFile(paramPath);
            }
        }
    }

解决方案 »

  1.   

    openFile文件选择控件设置允许多选,然后处理返回的文件对象数组,循环调用DeleteFile方法
      

  2.   


        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            private void Form1_Load(object sender, EventArgs e)
            {
                this.openFile.Multiselect = true;
            }
            private void DeleteFile(string[] str)
            {
                //string Path = paramPath.Substring(paramPath.LastIndexOf("\\") + 1);
                foreach (string FliePath in openFile.FileNames)
                {
                    if (System.IO.File.Exists(FliePath))
                    {
                        if (MessageBox.Show("Whether delete? \n" + FliePath, "Hint", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                        {
                           continue;
                        }
                        else
                        {
                            File.Delete(FliePath);
                            
                        }
                    }
                    //else
                    //{
                    //    MessageBox.Show("The document done not want to delete !");
                    //}
                }
                MessageBox.Show("The document deletes success!");
            }        private void btnDelete_Click(object sender, EventArgs e)
            {
                if (this.openFile.ShowDialog() == DialogResult.OK)
                {
                    string[] FliePath = this.openFile.FileNames;
                    this.DeleteFile(FliePath);
                }
            }
    下午已经解决了3Q!!!!