C# 將文件夾中文件複製到另外一個文件夾spa
//新建一個文件夾 var imgPath = Directory.GetCurrentDirectory() + "\\DevicePic1"; if (!Directory.Exists(imgPath)) { Directory.CreateDirectory(imgPath); } var a = picpath;//須要進行復制的圖片的路徑 var b= a.Substring(a.LastIndexOf('.'));//截取後綴名 var newname = imgPath + "\\rename" + b;//目標文件夾中文件的名稱,即將複製後對文件進行重命名 var nf = Path.Combine(newname);//將新的文件名稱路徑字符串結合成路徑。 File.Copy(a,nf);//進行文件複製,第一個參數是須要複製的文件路徑,第二個參數是目標文件夾中文件路徑 pictureBox2.Image=Image.FromFile(nf);