/// <Summary> /// Copy the file to extract the specified folder /// </ Summary> /// <param name = "by srcPath"> file folder path after extracting </ param> /// <param name = "aimPath"> specify the folder path </ param> public void copydir ( String by srcPath, String aimPath) { try { // Check if the target directory to directory If this is not the end of the character segmentation add IF (aimPath [aimPath.Length - 1 ]! = Path.DirectorySeparatorChar) { aimPath += Path.DirectorySeparatorChar; } // determine the target directory exists if there is no new IF (! Directory.Exists (aimPath)) { Directory.CreateDirectory(aimPath); } // get the source directory list of files, which are files that contain the array and a directory path // If you point to copy the target file does not contain the following files directory, please use the following method // String [] = fileList Directory.GetFiles (by srcPath); String [] = fileList Directory.GetFileSystemEntries (by srcPath); // loop through all the files and directories foreach ( String file in fileList) { // copy only PDF file IF (file.Substring (file.LastIndexOf ( " . " ) + 1 ) .ToUpper () == " PDF " ) { // first as a directory with files exist if this directory is the directory of the recursive Copy IF (Directory.Exists (File)) { CopyDir(file, aimPath + Path.GetFileName(file)); } // otherwise direct Copy file else { File.Copy(file, aimPath + Path.GetFileName(file), true); } } } } catch (Exception ex) { throw ex; } }