public void AddFiles(DirectoryInfo di)
{
if (di != null)
{
var files = new List<FileInfo>();
if (FileManager.SelectFiles( files ))
{
foreach (FileInfo fi in files)
{
bool newFile = true;
bool ok2Copy = true;
string target = Path.Combine( di.FullName, fi.Name );
if (File.Exists( target ))
{
newFile = false;
ok2Copy = false;
string message =
string.Format( "File \"{0}\" already exists, would you like to overwrite it?",
fi.Name );
if (DialogResult.Yes == MessageBox.Show( message,
@"V E R I F Y",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question ))
{
FileManager.DeleteFile( target );
ok2Copy = true;
//TODO: Overwrite file needs to be implemented.
//LogManager.Warn( "Overwrite file needs to be implemented." );
}
}
if (ok2Copy)
{
File.Copy( fi.FullName, target );
if (newFile)
{
var fileNew = new FileInfo( target );
OnAddFile( fileNew );
}
}
}
}
}
}