
代码如下:
//复制文件
private void btnCopy_Click(object sender, EventArgs e)
        {
            try
            {
                if (!File.Exists(this.txtFileName.Text))
                {
                    MessageBox.Show("文件不存在");
                }
                else
                {
                    File.Copy(this.txtFileName.Text, this.txtCopyName.Text);
                    MessageBox.Show("复制成功");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
//删除文件
        private void btnDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (!File.Exists(this.txtDelName.Text))
                {
                    MessageBox.Show("文件不存在!");
                }
                else
                {
                    File.Delete(this.txtDelName.Text);
                    MessageBox.Show("删除成功!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }