Class app
{
///
/// Copy all files for the specified directory, do not include subdirectory
/// summary>
/// Original directory param>
/// Target directory param>
/// If true, it means that the same name file is overwritten, otherwise it is not overwritten param>
Public Static Void CopyFiles (String Sourcedir, String Targetdir, Bool Overwrite)
{
CopyFiles (Sourcedir, Targetdir, Overwrite, False);
}
///
/// Copy all files for the specified directory
/// summary>
/// Original directory param>
/// Target directory param>
/// If true, override the same name file, otherwise it is not overwriting param>
/// If true, contains the directory, otherwise it does not include param>
Public Static Void CopyFiles (String Sourcedir, String Targetdir, Bool Overwrite, Bool CopyDir)
{
String [] FileEntries = Directory.getFiles (SOURCEDIR);
IF (OVERWRITE)
{
FOREACH (String Filename In Filentries)
{
File.copy (filename, targetdir filename.substring (filename.lastindexof ("//")), true);
//Console.writeline (FileName "--> " Targetdir FileName.Substring (FileName.lastIndexOf ("//"))));
}
}
Else
{
FOREACH (String Filename In Filentries)
{
IF (! file.exists (targetdir filename.substring (filename.lastindexof ("//")))))))))))
{
File.copy (FileName, Targetdir filename.substring (filename.lastindexof ("//"))));
//Console.writeline (FileName "--> " Targetdir FileName.Substring (FileName.lastIndexOf ("//"))));
}
}
}
IF (CopyDir)
{
FOREACH (String Subdir in Directory.GetDirector)
{
String newsubdir = targetdir subdir.substring (Subdir.lastIndexof ("//")); if (! Directory.exists (newsubdir))
Directory.createdIRectory (newsubdir);
CopyFiles (Subdir, NewSubdir, OverWrite, CopyDir);
}
}
}
}