71 {
72 sourceDirectoryName =
Path.GetFullPath(sourceDirectoryName);
73 destinationArchiveFileName =
Path.GetFullPath(destinationArchiveFileName);
74 using ZipArchive zipArchive =
Open(destinationArchiveFileName, ZipArchiveMode.Create, entryNameEncoding);
75 bool flag = true;
76 DirectoryInfo directoryInfo = new DirectoryInfo(sourceDirectoryName);
77 string fullName = directoryInfo.FullName;
78 if (includeBaseDirectory && directoryInfo.Parent != null)
79 {
80 fullName = directoryInfo.Parent.FullName;
81 }
83 try
84 {
85 foreach (FileSystemInfo
item in directoryInfo.EnumerateFileSystemInfos(
"*",
SearchOption.AllDirectories))
86 {
87 flag = false;
88 int length = item.FullName.Length - fullName.Length;
90 {
91 string entryName = ZipFileUtils.EntryFromPath(
item.FullName, fullName.Length,
length, ref
buffer);
92 zipArchive.DoCreateEntryFromFile(
item.FullName, entryName, compressionLevel);
93 }
94 else if (
item is DirectoryInfo possiblyEmptyDir && ZipFileUtils.IsDirEmpty(possiblyEmptyDir))
95 {
96 string entryName2 = ZipFileUtils.EntryFromPath(
item.FullName, fullName.Length,
length, ref
buffer, appendPathSeparator: true);
97 zipArchive.CreateEntry(entryName2);
98 }
99 }
100 if (includeBaseDirectory && flag)
101 {
102 zipArchive.CreateEntry(ZipFileUtils.EntryFromPath(directoryInfo.Name, 0, directoryInfo.Name.Length, ref
buffer, appendPathSeparator: true));
103 }
104 }
105 finally
106 {
108 }
109 }
static ArrayPool< T > Shared