private void BtnNewRecipe_Click(object sender, EventArgs e)
{
int index= Projectpaths[newRecipeForm.lBRecipe.SelectedIndex].LastIndexOf('\\');
string Newpath= Projectpaths[newRecipeForm.lBRecipe.SelectedIndex].Substring(0, index)+"\\" + newRecipeForm.tbNewRecipe.Text;
Directory.CreateDirectory(Newpath);
string[] files=Directory.GetFiles(Projectpaths[newRecipeForm.lBRecipe.SelectedIndex]);//获取文件完整路径
foreach (string file in files)
{
string name = System.IO.Path.GetFileName(file);//获取文件名和扩展名
string dest = System.IO.Path.Combine(Newpath, name);//新路径与复制文件名和扩展名结合新完整路径
System.IO.File.Copy(file, dest);//旧文件路径,新文件路径
}
MessageBox.Show("新建配方");
}
复制文件新路径
最新推荐文章于 2022-12-01 17:50:53 发布