1. Implement to copy all files under the specified folder to the specified path
1 Public Static voidCopyFiles (stringpath) { 2DirectoryInfo dir =NewDirectoryInfo (path);3 if(!dir. Exists)4 return;//get all the subdirectory information in the specified folder5directoryinfo[] dirs = dir. GetDirectories ();//get all the file information in the specified folder6fileinfo[] Files =dir. GetFiles (); 7 foreach(FileInfo fileinchfiles) { 8 stringFileName =file. Name; 9 stringDespath ="~/download-targetfiles/"+FileName;
File. CopyTo (Despath); Ten } One foreach(DirectoryInfo Dinchdirs) { A stringp =D.fullname; - CopyFiles (p); - } the } -
2. Implement modify the suffix name of the specified file
File.move ("C:\abc.txt","C:\abc.dat");
C # Implementation copies all files under the specified folder to the specified path and modifies the suffix name of the specified file