Dieser Snippet kopiert die übergebne Dateiliste.
/// <summary>
/// Copies the specified file list.
/// </summary>
/// <param name="fileList">The file list.</param>
/// <param name="targetFolder">The target folder.</param>
public static void Copy(IEnumerable<string> fileList, DirectoryInfo targetFolder)
{
#region conditions
Contract.Requires<ArgumentException>(fileList != null, "File List can't be null!");
Contract.Requires<ArgumentException>(targetFolder != null, "TargetFolder can't be null!");
Contract.Requires<ArgumentException>(targetFolder.Exists, "TargetFolder should exist!");
#endregion
string targetFile = null;
foreach (string curFile in fileList)
{
if (!String.IsNullOrEmpty(curFile) && System.IO.File.Exists(curFile))
{
targetFile = Path.Combine(targetFolder.FullName, System.IO.Path.GetFileName(curFile));
System.IO.File.Copy(curFile, targetFile);
}
}
}
Kommentare zum Snippet