Method for copying the entire folder (including subfolders)

xiaoxiao2021-03-06  20

Require references the namespace: use system.io;

///

/// Copy folder (including subfolders) Under the specified folder, the source folder and destination folders need an absolute path. Format: CopyFolder (source folder, destination folder); / // /// /// // ------------ -------------------------------------- // author: kgdiwss QQ: 305725744 // - -------------------------------------------------

Public Static Void CopyFolder (String strfromath) {// If the source folder does not exist, create if (! Directory.exists (strFromPath)) {Directory.createdIRectory (StrFromPath);

// Name String strfoldername = strFromPath.LastIndexof ("//") 1, strfromPath.length - strfromPath.LastInDexof ("/////////////////////////////////") - 1);

// If there is no source folder in the target folder, create a source folder if (! Directory.exists (STRFOLDERNAME)) {Directory.createdIRectory (Strtopath "//" Strfoldername);} // Create a file name String in an array save source folder [] strFiles = Directory.GetFiles (strFromPath);

转载请注明原文地址:https://www.9cbs.com/read-39694.html

New Post(0)