代码如下:
private void btncb_Click(object sender, EventArgs e)
{
//原路径
string path = filename;//一直到xx.xml
//拷贝到路径
string path2 = CodePath + @"\kaowj\检查表拷贝到.xml";
//初始化1
FileInfo soufile = new FileInfo(path);
//初始化2
FileInfo dest = new FileInfo(path2);
try
{
//如果拷贝的路径有这个文件 就删除
if (dest.Exists) dest.Delete();
//执行拷贝到xx
soufile.CopyTo(path2,true);
}
catch (Exception ex)
{
MessageBox.Show("拷贝错误"+ex.ToString());
}
}