private void Copydir (String srcpath, String aimpath)
{
Try
{
//checks whether the destination directory ends with a directory split character, if not, adds
if (aimpat H[AIMPATH.LENGTH-1]! = System.IO.Path.DirectorySeparatorChar)
{
Aimpath + = System.IO.Path.DirectorySeparatorChar;
}
//Determine if the destination directory exists if it does not exist, then create a new
if (! System.IO.Directory.Exists (Aimpath))
{
System.IO.Directory.CreateDirectory (aimpath);
}
//Get a list of files from the source directory, which is an array containing the files and directory paths
//If you point to a file below the copy destination file without a directory, use the following method
//string[] FileList = Directory.GetFiles (Srcpath);
string[] fileList = System.IO.Directory.GetFileSystemEntries (Srcpath);
// Traverse all files and directories
foreach (string file in FileList)
{
//first as directory processing if the directory is present, recursively copy the file under the directory
if (System.IO.Directory . Exists (file))
{
Copydir (file, Aimpath + System.IO.Path.GetFileName (file));
}
//Otherwise direct Copy file
Else
{
System.IO.File.Copy (file, Aimpath + System.IO.Path.GetFileName (file), true);
}
}
}
catch (Exception e)
{
throw;
}
}
C # implements methods for copying files from folders to another folder