这就是它到目前为止的样子,新手在这里如此,我将不胜感激任何提示或建议。
private void btn_browse_Click(object sender, EventArgs e)
{
FolderBrowserDialog open = new FolderBrowserDialog();
if (open.ShowDialog()==DialogResult.OK)
{
tb_path.Text = open.SelectedPath;
}
}
private void btn_browse_2_Click(object sender, EventArgs e)
{
FolderBrowserDialog open = new FolderBrowserDialog();
if (open.ShowDialog() == DialogResult.OK)
{
tb_dest.Text = open.SelectedPath;
}
}
private void btn_copy_Click(object sender, EventArgs e)
{
if (!Directory.Exists(tb_dest.Text))
{
Directory.CreateDirectory(tb_dest.Text);
}
foreach (var path in Directory.GetFiles(tb_path.Text))
{
File.Copy(path, path.Replace(tb_path.Text, tb_dest.Text), true);
}
}
这当前只将文件从一个选定目录复制到另一个选定目录。当我将文件复制到目标目录时,如果有一个名称相同的文件会覆盖它,那就是问题。