XCOPY是COPY的擴充,可以把指定的目錄連檔案和目錄結構一併拷貝,但不能拷貝系統檔案;使用時來源硬碟符、源目標路徑名、源檔案名稱至少指定一個;選用/S時對來源目錄下及其子目錄下的所有檔案進行COPY。除非指定/E參數,否則/S不會拷貝空目錄,若不指定/S參數,則XCOPY只拷貝來源目錄本身的檔案,而不涉及其下的子目錄;選用/V參數時,對拷貝的扇區都進行較驗,但速度會降低。
<?php /************************************** 系統名稱:類比xcopy的函數* 程式功能:類比xcopy的函數*************************************/?><?//copy a direction's all files to another direction function xCopy($source, $destination, $child){ //用法: // xCopy("feiy","feiy2",1):拷貝feiy下的檔案到 feiy2,包括子目錄 // xCopy("feiy","feiy2",0):拷貝feiy下的檔案到 feiy2,不包括子目錄 //參數說明: // $source:來源目錄名 // $destination:目的目錄名 // $child:複製時,是不是包含的子目錄 if(!is_dir($source)){ echo("Error:the $source is not a direction!"); return 0; } if(!is_dir($destination)){ mkdir($destination,0777); } $handle=dir($source); while($entry=$handle->read()) { if(($entry!=".")&&($entry!="..")){ if(is_dir($source."/".$entry)){ if($child) xCopy($source."/".$entry,$destination."/".$entry,$child); } else{ copy($source."/".$entry,$destination."/".$entry); } } } return 1; } ?>