Introduction
Sometimes we need to copy an image from one folder to another folder. The snippet shows how to copy file using System.IO.File.Copy.
System.IO.File.Copy(Server.MapPath("/sourcefolder/myimage.jpg"), Server.MapPath("/destinationfolder/myimage1.jpg"));
Copy method takes 2 arguments
1st - source file path
2nd - destination file path
sourcefolder & destinationfolder are folders in your ASP.NET project.
Note: Server.MapPath works for ASP.NET. If you want to use it for console/windows application just pass the path of the file like below
System.IO.File.Copy(@"c:\myimage.jpg", @"c:\testfolder\myimage1.jpg");