File management class fileInfo and file

xiaoxiao2021-03-06  45

FileInfo.copy () cannot copy the content of the entire folder. If you need to copy the content of the entire folder, you need to copy each file separately, and build the same folder name of the old directory! ~ Khan ~~ This troubles ~ By checking EXISTS, you can determine if the file exists! ///

/// copy all files of the specified directory, does not include subdirectories /// /// Original directory /// Target directory /// If true, it means that the same name file is overwritten, otherwise it is not overwriting public static Void CopyFiles (String SourceDir, String Targetdir, Bool Overwrite) {CopyFiles (SourceDir, Targetdir, Overwrite, False);} /// /// copy specified directory //// ///// Original directory /// target directory /// If true, override the same name file, Otherwise, it is not overwritten /// If true, contains the directory, otherwise it does not include public static void CopyFiles (String Sourcedir, String Targetdir, Bool Overwrite, Bool CopyDir) { string [] fileEntries = Directory.GetFiles (sourceDir); if (overWrite) {foreach (string fileName in fileEntries) {File.Copy (fileName, targetDir fileName.Substring (fileName.LastIndexOf ( "//")), true) ; //Console.writeline (FileName "-> " targetdir FileName.Substring (FileName.lastIndexOf ("//")));}}} else {foreach (String FileName In FileEntries) {if (! File.exists) Targetdir filename.substring (filename.lastIndexof ("//")))) {file.copy (filename, targetdir filename.substring ("//"))); ///console.writeline (FileName "->" Targetdir filename.substring (filename.lastindexof ("//")))))

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

New Post(0)