/// <summary>压缩</summary> /// <param name="di"></param> /// <param name="destFile"></param> public static void Compress(this DirectoryInfo di, String destFile = null) { if (destFile.IsNullOrEmpty()) { destFile = di.Name + ".zip"; } if (File.Exists(destFile)) { File.Delete(destFile); } if (destFile.EndsWithIgnoreCase(".zip")) #if NET4 { ZipFile.CompressDirectory(di.FullName, destFile); } #else { ZipFile.CreateFromDirectory(di.FullName, destFile, CompressionLevel.Optimal, true); }