是否可以使用暂停/恢复功能?
source.copyTo(destination);
如果你最早能发送它会很棒。
答案 0 :(得分:5)
我在这里找到了一个解决方案CookBook from Adobe
private function copyInto(directoryToCopy:File, locationCopyingTo:File):void
{
var directory:Array = directoryToCopy.getDirectoryListing();
for each (var f:File in directory)
{
if (f.isDirectory)
copyInto(f, locationCopyingTo.resolvePath(f.name));
else
f.copyTo(locationCopyingTo.resolvePath(f.name), true);
}
}
答案 1 :(得分:1)
或者你可以使用File.copyTo()方法:
var source:File = new File();
source.resolvePath( 'sourceFolder' );
var destination:File = new File();
destination.resolvePath( 'destinationFolder' );
source.copyTo( destination );
如果目录很大并且您不希望应用程序卡在等待副本,则可以使用copyToAsync,这将导致源文件在作业完成时调度Event.COMPLETE。
答案 2 :(得分:0)
如果有人想复制整个目录,这是上面修改过的代码;空文件夹和所有。注意参数中使用的“copyEmptyFolders”参数。
//Recursivley copies directory.
private static function copyInto(directoryToCopy:File, locationCopyingTo:File, copyEmptyFolders:Boolean=true):void
{
var directory:Array = directoryToCopy.getDirectoryListing();
for each (var f:File in directory)
{
if (f.isDirectory)
{
// Copies a folder whether it is empty or not.
if( copyEmptyFolders ) f.copyTo(locationCopyingTo.resolvePath(f.name), true);
// Recurse thru folder.
copyInto(f, locationCopyingTo.resolvePath(f.name));
}
else
f.copyTo(locationCopyingTo.resolvePath(f.name), true);
}
}