ThreadAbortException lors d'un CopyTo
bonjour, j'ai une méthode de copie de dossiers :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| private void CopierDossier(string sourcePath, string destPath, bool overwrite)
{
log.Info(string.Format("CopierDossier : copie du dossier {0} vers {1}", sourcePath, destPath));
System.IO.DirectoryInfo sourceDir = new System.IO.DirectoryInfo(sourcePath);
System.IO.DirectoryInfo destDir = new System.IO.DirectoryInfo(destPath);
if (sourceDir.Exists)
{
if (!destDir.Exists)
destDir.Create();
// copie des fichiers
foreach (System.IO.FileInfo file in sourceDir.GetFiles())
{
try
{
if (overwrite)
file.CopyTo(System.IO.Path.Combine(destDir.FullName, file.Name), true);
else if ((System.IO.File.Exists(System.IO.Path.Combine(destDir.FullName, file.Name))) == false)
file.CopyTo(System.IO.Path.Combine(destDir.FullName, file.Name), false);
}
catch (Exception e)
{
log.Error(string.Format("Erreur lors de la copie de {0} vers {1}", file.FullName, System.IO.Path.Combine(destDir.FullName, file.Name)), e);
throw e;
}
}
// copie des dossiers
foreach (System.IO.DirectoryInfo dir in sourceDir.GetDirectories())
{
CopierDossier(dir.FullName, System.IO.Path.Combine(destDir.FullName, dir.Name), overwrite);
}
}
} |
qui parfois m'explose à la tête en un :
Code:
1 2 3 4
| 2009-06-23 10:28:48,025 [7] ERROR - System.Threading.ThreadAbortException: Le thread a été abandonné.
à Microsoft.Win32.Win32Native.CopyFile(String src, String dst, Boolean failIfExists)
à System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
à System.IO.FileInfo.CopyTo(String destFileName, Boolean overwrite) |
Sachant que la plupart du temps, cela passe.
Est ce que quelqu'un aurait une idée de l'origine et pourquoi directement une ThreadAbortException ?