在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
private void Copy() { DirectoryInfo dir = new DirectoryInfo("c:\\CSS"); CopyDirectorysAndFiles("c:\\test", dir); } private void CopyDirectorysAndFiles(string dest, DirectoryInfo srcdir) { if (dest.LastIndexOf('\\') != (dest.Length - 1)) { dest += "\\"; } string destPath = dest +srcdir.Name + "\\"; if (!Directory.Exists(destPath)) { Directory.CreateDirectory(destPath); } FileInfo[] files = srcdir.GetFiles(); foreach (FileInfo file in files) { file.CopyTo(destPath + file.Name, true); } DirectoryInfo[] dirs = srcdir.GetDirectories(); foreach (DirectoryInfo dirInfo in dirs) { CopyDirectorysAndFiles(destPath, dirInfo); } }
----------------------------------- File.Move(FileOldPath,FileNewPath) 或者File.Copy(FileOldPath,FileNewPath) System.IO.File.Move(File, newfile); System.IO.File.Copy(File, newfile); System.IO.File.Detele(File); |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论