-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathZipFile.xml
More file actions
2994 lines (2710 loc) · 246 KB
/
ZipFile.xml
File metadata and controls
2994 lines (2710 loc) · 246 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<Type Name="ZipFile" FullName="System.IO.Compression.ZipFile">
<TypeSignature Language="C#" Value="public static class ZipFile" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract sealed beforefieldinit ZipFile extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.IO.Compression.ZipFile" />
<TypeSignature Language="VB.NET" Value="Public Class ZipFile" />
<TypeSignature Language="F#" Value="type ZipFile = class" />
<TypeSignature Language="C++ CLI" Value="public ref class ZipFile abstract sealed" />
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>4.0.4.0</AssemblyVersion>
<AssemblyVersion>4.0.5.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.FileSystem</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeForwardingChain>
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.IO.Compression.ZipFile" ToVersion="10.0.0.0" FrameworkAlternate="net-10.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.IO.Compression.ZipFile" ToVersion="11.0.0.0" FrameworkAlternate="net-11.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.IO.Compression.ZipFile" ToVersion="5.0.0.0" FrameworkAlternate="net-5.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.IO.Compression.ZipFile" ToVersion="6.0.0.0" FrameworkAlternate="net-6.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.IO.Compression.ZipFile" ToVersion="7.0.0.0" FrameworkAlternate="net-7.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.IO.Compression.ZipFile" ToVersion="8.0.0.0" FrameworkAlternate="net-8.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.IO.Compression.ZipFile" ToVersion="9.0.0.0" FrameworkAlternate="net-9.0" />
</TypeForwardingChain>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute FrameworkAlternate="net-10.0;net-11.0;net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(0)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(0)>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Provides static methods for creating, extracting, and opening zip archives.</summary>
<remarks>
<format type="text/markdown"><]
]]></format>
</remarks>
</Docs>
<Members>
<MemberGroup MemberName="CreateFromDirectory">
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Creates a zip archive that contains the files and directories from the specified directory.</summary>
</Docs>
</MemberGroup>
<Member MemberName="CreateFromDirectory">
<MemberSignature Language="C#" Value="public static void CreateFromDirectory (string sourceDirectoryName, System.IO.Stream destination);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void CreateFromDirectory(string sourceDirectoryName, class System.IO.Stream destination) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.CreateFromDirectory(System.String,System.IO.Stream)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub CreateFromDirectory (sourceDirectoryName As String, destination As Stream)" />
<MemberSignature Language="F#" Value="static member CreateFromDirectory : string * System.IO.Stream -> unit" Usage="System.IO.Compression.ZipFile.CreateFromDirectory (sourceDirectoryName, destination)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void CreateFromDirectory(System::String ^ sourceDirectoryName, System::IO::Stream ^ destination);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sourceDirectoryName" Type="System.String" Index="0" FrameworkAlternate="net-8.0;net-9.0;net-10.0;net-11.0" />
<Parameter Name="destination" Type="System.IO.Stream" Index="1" FrameworkAlternate="net-8.0;net-9.0;net-10.0;net-11.0" />
</Parameters>
<Docs>
<param name="sourceDirectoryName">The path to the directory to be archived, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<param name="destination">The stream where the zip archive is to be stored.</param>
<summary>Creates a zip archive in the specified stream that contains the files and directories from the specified directory.</summary>
<remarks>The directory structure from the file system is preserved in the archive. If the directory is empty, an empty archive is created.
This method overload does not include the base directory in the archive and does not allow you to specify a compression level.
If you want to include the base directory or specify a compression level, call the <see cref="M:System.IO.Compression.ZipFile.CreateFromDirectory(System.String,System.IO.Stream,System.IO.Compression.CompressionLevel,System.Boolean)" /> method overload.
If a file in the directory cannot be added to the archive, the archive is left incomplete and invalid, and the method throws an <see cref="T:System.IO.IOException" /> exception.</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="sourceDirectoryName" /> is <see cref="F:System.String.Empty" />, contains only white space, or contains at least one invalid character.
-or-
The <paramref name="destination" /> stream does not support writing.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="sourceDirectoryName" /> or <paramref name="destination" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">In <paramref name="sourceDirectoryName" />, the specified path, file name, or both exceed the system-defined maximum length.</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">
<paramref name="sourceDirectoryName" /> is invalid or does not exist (for example, it is on an unmapped drive).</exception>
<exception cref="T:System.IO.IOException">A file in the specified directory could not be opened.
-or-
An I/O error occurred while opening a file to be archived.</exception>
<exception cref="T:System.NotSupportedException">
<paramref name="sourceDirectoryName" /> contains an invalid format.</exception>
</Docs>
</Member>
<Member MemberName="CreateFromDirectory">
<MemberSignature Language="C#" Value="public static void CreateFromDirectory (string sourceDirectoryName, string destinationArchiveFileName);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.CreateFromDirectory(System.String,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub CreateFromDirectory (sourceDirectoryName As String, destinationArchiveFileName As String)" />
<MemberSignature Language="F#" Value="static member CreateFromDirectory : string * string -> unit" Usage="System.IO.Compression.ZipFile.CreateFromDirectory (sourceDirectoryName, destinationArchiveFileName)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void CreateFromDirectory(System::String ^ sourceDirectoryName, System::String ^ destinationArchiveFileName);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>4.0.4.0</AssemblyVersion>
<AssemblyVersion>4.0.5.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.FileSystem</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sourceDirectoryName" Type="System.String" />
<Parameter Name="destinationArchiveFileName" Type="System.String" />
</Parameters>
<Docs>
<param name="sourceDirectoryName">The path to the directory to be archived, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<param name="destinationArchiveFileName">The path of the archive to be created, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<summary>Creates a zip archive that contains the files and directories from the specified directory.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The directory structure from the file system is preserved in the archive. If the directory is empty, an empty archive is created. This method overload does not include the base directory in the archive and does not allow you to specify a compression level. If you want to include the base directory or specify a compression level, call the <xref:System.IO.Compression.ZipFile.CreateFromDirectory%28System.String%2CSystem.String%2CSystem.IO.Compression.CompressionLevel%2CSystem.Boolean%29> method overload.
If the archive already exists, an <xref:System.IO.IOException> exception is thrown. If an entry with the specified name already exists in the archive, a second entry is created with an identical name.
If a file in the directory cannot be added to the archive, the archive is left incomplete and invalid, and the method throws an <xref:System.IO.IOException> exception.
## Examples
This example shows how to create and extract a zip archive by using the <xref:System.IO.Compression.ZipFile> class. It compresses the contents of a folder into a zip archive, and then extracts that content to a new folder. To use the <xref:System.IO.Compression.ZipFile> class, you must reference the `System.IO.Compression.FileSystem` assembly in your project.
:::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipFile/CreateFromDirectory/program1.cs" id="Snippet1":::
:::code language="fsharp" source="~/snippets/fsharp/System.IO.Compression/ZipFile/CreateFromDirectory/program1.fs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipFile/CreateFromDirectory/program1.vb" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is <see cref="F:System.String.Empty" />, contains only white space, or contains at least one invalid character.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">In <paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" />, the specified path, file name, or both exceed the system-defined maximum length.</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">
<paramref name="sourceDirectoryName" /> is invalid or does not exist (for example, it is on an unmapped drive).</exception>
<exception cref="T:System.IO.IOException">
<paramref name="destinationArchiveFileName" /> already exists.
-or-
A file in the specified directory could not be opened.
-or-
An I/O error occurred while opening a file to be archived.</exception>
<exception cref="T:System.UnauthorizedAccessException">
<paramref name="destinationArchiveFileName" /> specifies a directory.
-or-
The caller does not have the required permission to access the directory specified in <paramref name="sourceDirectoryName" /> or the file specified in <paramref name="destinationArchiveFileName" />.</exception>
<exception cref="T:System.NotSupportedException">
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> contains an invalid format.
-or-
The zip archive does not support writing.</exception>
</Docs>
</Member>
<Member MemberName="CreateFromDirectory">
<MemberSignature Language="C#" Value="public static void CreateFromDirectory (string sourceDirectoryName, System.IO.Stream destination, System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void CreateFromDirectory(string sourceDirectoryName, class System.IO.Stream destination, valuetype System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.CreateFromDirectory(System.String,System.IO.Stream,System.IO.Compression.CompressionLevel,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub CreateFromDirectory (sourceDirectoryName As String, destination As Stream, compressionLevel As CompressionLevel, includeBaseDirectory As Boolean)" />
<MemberSignature Language="F#" Value="static member CreateFromDirectory : string * System.IO.Stream * System.IO.Compression.CompressionLevel * bool -> unit" Usage="System.IO.Compression.ZipFile.CreateFromDirectory (sourceDirectoryName, destination, compressionLevel, includeBaseDirectory)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void CreateFromDirectory(System::String ^ sourceDirectoryName, System::IO::Stream ^ destination, System::IO::Compression::CompressionLevel compressionLevel, bool includeBaseDirectory);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sourceDirectoryName" Type="System.String" Index="0" FrameworkAlternate="net-8.0;net-9.0;net-10.0;net-11.0" />
<Parameter Name="destination" Type="System.IO.Stream" Index="1" FrameworkAlternate="net-8.0;net-9.0;net-10.0;net-11.0" />
<Parameter Name="compressionLevel" Type="System.IO.Compression.CompressionLevel" Index="2" FrameworkAlternate="net-8.0;net-9.0;net-10.0;net-11.0" />
<Parameter Name="includeBaseDirectory" Type="System.Boolean" Index="3" FrameworkAlternate="net-8.0;net-9.0;net-10.0;net-11.0" />
</Parameters>
<Docs>
<param name="sourceDirectoryName">The path to the directory to be archived, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<param name="destination">The stream where the zip archive is to be stored.</param>
<param name="compressionLevel">One of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry.</param>
<param name="includeBaseDirectory">
<see langword="true" /> to include the directory name from <paramref name="sourceDirectoryName" /> at the root of the archive; <see langword="false" /> to include only the contents of the directory.</param>
<summary>Creates a zip archive in the specified stream that contains the files and directories from the specified directory, uses the specified compression level, and optionally includes the base directory.</summary>
<remarks>The directory structure from the file system is preserved in the archive. If the directory is empty, an empty archive is created.
Use this method overload to specify the compression level and whether to include the base directory in the archive.
If a file in the directory cannot be added to the archive, the archive is left incomplete and invalid, and the method throws an <see cref="T:System.IO.IOException" /> exception.</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="sourceDirectoryName" /> is <see cref="F:System.String.Empty" />, contains only white space, or contains at least one invalid character.
-or-
The <paramref name="destination" /> stream does not support writing.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="sourceDirectoryName" /> or <paramref name="destination" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">In <paramref name="sourceDirectoryName" />, the specified path, file name, or both exceed the system-defined maximum length.</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">
<paramref name="sourceDirectoryName" /> is invalid or does not exist (for example, it is on an unmapped drive).</exception>
<exception cref="T:System.IO.IOException">A file in the specified directory could not be opened.
-or-
An I/O error occurred while opening a file to be archived.</exception>
<exception cref="T:System.NotSupportedException">
<paramref name="sourceDirectoryName" /> contains an invalid format.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="compressionLevel" /> is not a valid <see cref="T:System.IO.Compression.CompressionLevel" /> value.</exception>
</Docs>
</Member>
<Member MemberName="CreateFromDirectory">
<MemberSignature Language="C#" Value="public static void CreateFromDirectory (string sourceDirectoryName, string destinationArchiveFileName, System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, valuetype System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.CreateFromDirectory(System.String,System.String,System.IO.Compression.CompressionLevel,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub CreateFromDirectory (sourceDirectoryName As String, destinationArchiveFileName As String, compressionLevel As CompressionLevel, includeBaseDirectory As Boolean)" />
<MemberSignature Language="F#" Value="static member CreateFromDirectory : string * string * System.IO.Compression.CompressionLevel * bool -> unit" Usage="System.IO.Compression.ZipFile.CreateFromDirectory (sourceDirectoryName, destinationArchiveFileName, compressionLevel, includeBaseDirectory)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void CreateFromDirectory(System::String ^ sourceDirectoryName, System::String ^ destinationArchiveFileName, System::IO::Compression::CompressionLevel compressionLevel, bool includeBaseDirectory);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>4.0.4.0</AssemblyVersion>
<AssemblyVersion>4.0.5.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.FileSystem</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sourceDirectoryName" Type="System.String" />
<Parameter Name="destinationArchiveFileName" Type="System.String" />
<Parameter Name="compressionLevel" Type="System.IO.Compression.CompressionLevel" />
<Parameter Name="includeBaseDirectory" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="sourceDirectoryName">The path to the directory to be archived, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<param name="destinationArchiveFileName">The path of the archive to be created, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<param name="compressionLevel">One of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry.</param>
<param name="includeBaseDirectory">
<see langword="true" /> to include the directory name from <paramref name="sourceDirectoryName" /> at the root of the archive; <see langword="false" /> to include only the contents of the directory.</param>
<summary>Creates a zip archive that contains the files and directories from the specified directory, uses the specified compression level, and optionally includes the base directory.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The directory structure from the file system is preserved in the archive. If the directory is empty, an empty archive is created. Use this method overload to specify the compression level and whether to include the base directory in the archive.
If the archive already exists, an <xref:System.IO.IOException> exception is thrown. If an entry with the specified name already exists in the archive, a second entry is created with an identical name.
If a file in the directory cannot be added to the archive, the archive is left incomplete and invalid, and the method throws an <xref:System.IO.IOException> exception.
## Examples
This example shows how to create and extract a zip archive by using the <xref:System.IO.Compression.ZipFile> class. It compresses the contents of a folder into a zip archive, and then extracts that content to a new folder. When compressing the archive, the base directory is included and the compression level is set to emphasize the speed of the operation over efficiency. To use the <xref:System.IO.Compression.ZipFile> class, you must reference the `System.IO.Compression.FileSystem` assembly in your project.
:::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipFile/CreateFromDirectory/program2.cs" id="Snippet2":::
:::code language="fsharp" source="~/snippets/fsharp/System.IO.Compression/ZipFile/CreateFromDirectory/program2.fs" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipFile/CreateFromDirectory/program2.vb" id="Snippet2":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is <see cref="F:System.String.Empty" />, contains only white space, or contains at least one invalid character.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">In <paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" />, the specified path, file name, or both exceed the system-defined maximum length.</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">
<paramref name="sourceDirectoryName" /> is invalid or does not exist (for example, it is on an unmapped drive).</exception>
<exception cref="T:System.IO.IOException">
<paramref name="destinationArchiveFileName" /> already exists.
-or-
A file in the specified directory could not be opened.
-or-
An I/O error occurred while opening a file to be archived.</exception>
<exception cref="T:System.UnauthorizedAccessException">
<paramref name="destinationArchiveFileName" /> specifies a directory.
-or-
The caller does not have the required permission to access the directory specified in <paramref name="sourceDirectoryName" /> or the file specified in <paramref name="destinationArchiveFileName" />.</exception>
<exception cref="T:System.NotSupportedException">
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> contains an invalid format.
-or-
The zip archive does not support writing.</exception>
</Docs>
</Member>
<Member MemberName="CreateFromDirectory">
<MemberSignature Language="C#" Value="public static void CreateFromDirectory (string sourceDirectoryName, System.IO.Stream destination, System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory, System.Text.Encoding? entryNameEncoding);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void CreateFromDirectory(string sourceDirectoryName, class System.IO.Stream destination, valuetype System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory, class System.Text.Encoding entryNameEncoding) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.CreateFromDirectory(System.String,System.IO.Stream,System.IO.Compression.CompressionLevel,System.Boolean,System.Text.Encoding)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub CreateFromDirectory (sourceDirectoryName As String, destination As Stream, compressionLevel As CompressionLevel, includeBaseDirectory As Boolean, entryNameEncoding As Encoding)" />
<MemberSignature Language="F#" Value="static member CreateFromDirectory : string * System.IO.Stream * System.IO.Compression.CompressionLevel * bool * System.Text.Encoding -> unit" Usage="System.IO.Compression.ZipFile.CreateFromDirectory (sourceDirectoryName, destination, compressionLevel, includeBaseDirectory, entryNameEncoding)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void CreateFromDirectory(System::String ^ sourceDirectoryName, System::IO::Stream ^ destination, System::IO::Compression::CompressionLevel compressionLevel, bool includeBaseDirectory, System::Text::Encoding ^ entryNameEncoding);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sourceDirectoryName" Type="System.String" Index="0" FrameworkAlternate="net-8.0;net-9.0;net-10.0;net-11.0" />
<Parameter Name="destination" Type="System.IO.Stream" Index="1" FrameworkAlternate="net-8.0;net-9.0;net-10.0;net-11.0" />
<Parameter Name="compressionLevel" Type="System.IO.Compression.CompressionLevel" Index="2" FrameworkAlternate="net-8.0;net-9.0;net-10.0;net-11.0" />
<Parameter Name="includeBaseDirectory" Type="System.Boolean" Index="3" FrameworkAlternate="net-8.0;net-9.0;net-10.0;net-11.0" />
<Parameter Name="entryNameEncoding" Type="System.Text.Encoding" Index="4" FrameworkAlternate="net-8.0;net-9.0;net-10.0;net-11.0">
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(2)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(2)>]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="sourceDirectoryName">The path to the directory to be archived, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<param name="destination">The stream where the zip archive is to be stored.</param>
<param name="compressionLevel">One of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry.</param>
<param name="includeBaseDirectory">
<see langword="true" /> to include the directory name from <paramref name="sourceDirectoryName" /> at the root of the archive; <see langword="false" /> to include only the contents of the directory.</param>
<param name="entryNameEncoding">The encoding to use when reading or writing entry names and comments in this archive. Specify a value for this parameter only when an encoding is required for interoperability with zip archive tools and libraries that do not support UTF-8 encoding for entry names or comments.</param>
<summary>Creates a zip archive in the specified stream that contains the files and directories from the specified directory, uses the specified compression level and character encoding for entry names and comments, and optionally includes the base directory.</summary>
<remarks>The directory structure from the file system is preserved in the archive. If the directory is empty, an empty archive is created.
Use this method overload to specify the compression level and character encoding, and whether to include the base directory in the archive.
If a file in the directory cannot be added to the archive, the archive is left incomplete and invalid, and the method throws an <see cref="T:System.IO.IOException" /> exception.</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="sourceDirectoryName" /> is <see cref="F:System.String.Empty" />, contains only white space, or contains at least one invalid character.
-or-
The <paramref name="destination" /> stream does not support writing.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="sourceDirectoryName" /> or <paramref name="destination" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">In <paramref name="sourceDirectoryName" />, the specified path, file name, or both exceed the system-defined maximum length.</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">
<paramref name="sourceDirectoryName" /> is invalid or does not exist (for example, it is on an unmapped drive).</exception>
<exception cref="T:System.IO.IOException">A file in the specified directory could not be opened.
-or-
An I/O error occurred while opening a file to be archived.</exception>
<exception cref="T:System.NotSupportedException">
<paramref name="sourceDirectoryName" /> contains an invalid format.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="compressionLevel" /> is not a valid <see cref="T:System.IO.Compression.CompressionLevel" /> value.</exception>
</Docs>
</Member>
<Member MemberName="CreateFromDirectory">
<MemberSignature Language="C#" Value="public static void CreateFromDirectory (string sourceDirectoryName, string destinationArchiveFileName, System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory, System.Text.Encoding entryNameEncoding);" FrameworkAlternate="dotnet-uwp-10.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.3;netstandard-1.4;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void CreateFromDirectory(string sourceDirectoryName, string destinationArchiveFileName, valuetype System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory, class System.Text.Encoding entryNameEncoding) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.CreateFromDirectory(System.String,System.String,System.IO.Compression.CompressionLevel,System.Boolean,System.Text.Encoding)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub CreateFromDirectory (sourceDirectoryName As String, destinationArchiveFileName As String, compressionLevel As CompressionLevel, includeBaseDirectory As Boolean, entryNameEncoding As Encoding)" />
<MemberSignature Language="F#" Value="static member CreateFromDirectory : string * string * System.IO.Compression.CompressionLevel * bool * System.Text.Encoding -> unit" Usage="System.IO.Compression.ZipFile.CreateFromDirectory (sourceDirectoryName, destinationArchiveFileName, compressionLevel, includeBaseDirectory, entryNameEncoding)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void CreateFromDirectory(System::String ^ sourceDirectoryName, System::String ^ destinationArchiveFileName, System::IO::Compression::CompressionLevel compressionLevel, bool includeBaseDirectory, System::Text::Encoding ^ entryNameEncoding);" />
<MemberSignature Language="C#" Value="public static void CreateFromDirectory (string sourceDirectoryName, string destinationArchiveFileName, System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory, System.Text.Encoding? entryNameEncoding);" FrameworkAlternate="net-10.0;net-11.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
<AssemblyVersion>4.0.4.0</AssemblyVersion>
<AssemblyVersion>4.0.5.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.FileSystem</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sourceDirectoryName" Type="System.String" />
<Parameter Name="destinationArchiveFileName" Type="System.String" />
<Parameter Name="compressionLevel" Type="System.IO.Compression.CompressionLevel" />
<Parameter Name="includeBaseDirectory" Type="System.Boolean" />
<Parameter Name="entryNameEncoding" Type="System.Text.Encoding">
<Attributes>
<Attribute FrameworkAlternate="net-10.0;net-11.0;net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(2)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(2)>]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="sourceDirectoryName">The path to the directory to be archived, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<param name="destinationArchiveFileName">The path of the archive to be created, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<param name="compressionLevel">One of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry.</param>
<param name="includeBaseDirectory">
<see langword="true" /> to include the directory name from <paramref name="sourceDirectoryName" /> at the root of the archive; <see langword="false" /> to include only the contents of the directory.</param>
<param name="entryNameEncoding">The encoding to use when reading or writing entry names and comments in this archive. Specify a value for this parameter only when an encoding is required for interoperability with zip archive tools and libraries that do not support UTF-8 encoding for entry names or comments.</param>
<summary>Creates a zip archive that contains the files and directories from the specified directory, uses the specified compression level and character encoding for entry names and comments, and optionally includes the base directory.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The directory structure from the file system is preserved in the archive. If the directory is empty, an empty archive is created. Use this method overload to specify the compression level and character encoding, and whether to include the base directory in the archive.
If the archive already exists, an <xref:System.IO.IOException> exception is thrown. If an entry with the specified name already exists in the archive, a second entry is created with an identical name.
If a file in the directory cannot be added to the archive, the archive is left incomplete and invalid, and the method throws an <xref:System.IO.IOException> exception.
If `entryNameEncoding` is set to a value other than `null`, the entry names and comments are encoded by using the specified encoding. If the specified encoding is a UTF-8 encoding, the language encoding flag (in the general-purpose bit flag of the local file header) is set for each entry.
If `entryNameEncoding` is set to `null`, the entry names and comments are encoded according to the following rules:
- For entry names and comments that contain characters outside the ASCII range, the language encoding flag is set, and UTF-8 is used to encode the entry name and comment.
- For entry names and comments that contain only ASCII characters, the language encoding flag is not set, and the current system default code page is used to encode the entry names and comments.
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is <see cref="F:System.String.Empty" />, contains only white space, or contains at least one invalid character.
-or-
<paramref name="entryNameEncoding" /> is set to a Unicode encoding other than UTF-8.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">In <paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" />, the specified path, file name, or both exceed the system-defined maximum length.</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">
<paramref name="sourceDirectoryName" /> is invalid or does not exist (for example, it is on an unmapped drive).</exception>
<exception cref="T:System.IO.IOException">
<paramref name="destinationArchiveFileName" /> already exists.
-or-
A file in the specified directory could not be opened.
-or-
An I/O error occurred while opening a file to be archived.</exception>
<exception cref="T:System.UnauthorizedAccessException">
<paramref name="destinationArchiveFileName" /> specifies a directory.
-or-
The caller does not have the required permission to access the directory specified in <paramref name="sourceDirectoryName" /> or the file specified in <paramref name="destinationArchiveFileName" />.</exception>
<exception cref="T:System.NotSupportedException">
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> contains an invalid format.
-or-
The zip archive does not support writing.</exception>
</Docs>
</Member>
<Member MemberName="CreateFromDirectoryAsync">
<MemberSignature Language="C#" Value="public static System.Threading.Tasks.Task CreateFromDirectoryAsync (string sourceDirectoryName, System.IO.Stream destination, System.Threading.CancellationToken cancellationToken = default);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Threading.Tasks.Task CreateFromDirectoryAsync(string sourceDirectoryName, class System.IO.Stream destination, valuetype System.Threading.CancellationToken cancellationToken) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.CreateFromDirectoryAsync(System.String,System.IO.Stream,System.Threading.CancellationToken)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function CreateFromDirectoryAsync (sourceDirectoryName As String, destination As Stream, Optional cancellationToken As CancellationToken = Nothing) As Task" />
<MemberSignature Language="F#" Value="static member CreateFromDirectoryAsync : string * System.IO.Stream * System.Threading.CancellationToken -> System.Threading.Tasks.Task" Usage="System.IO.Compression.ZipFile.CreateFromDirectoryAsync (sourceDirectoryName, destination, cancellationToken)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.Tasks.Task</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sourceDirectoryName" Type="System.String" Index="0" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="destination" Type="System.IO.Stream" Index="1" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="cancellationToken" Type="System.Threading.CancellationToken" Index="2" FrameworkAlternate="net-10.0;net-11.0" />
</Parameters>
<Docs>
<param name="sourceDirectoryName">The path to the directory to be archived, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<param name="destination">The stream where the zip archive is to be stored.</param>
<param name="cancellationToken">The cancellation token to monitor for cancellation requests.</param>
<summary>Asynchronously creates a zip archive in the specified stream that contains the files and directories from the specified directory.</summary>
<returns>To be added.</returns>
<remarks>
<para>The directory structure from the file system is preserved in the archive. If the directory is empty, an empty archive is created.</para>
<para>This method overload does not include the base directory in the archive and does not allow you to specify a compression level.</para>
<para>If you want to include the base directory or specify a compression level, call the <see cref="M:System.IO.Compression.ZipFile.CreateFromDirectory(System.String,System.IO.Stream,System.IO.Compression.CompressionLevel,System.Boolean)" /> method overload.</para>
<para>If a file in the directory cannot be added to the archive, the archive is left incomplete and invalid, and the method throws an <see cref="T:System.IO.IOException" /> exception.</para>
</remarks>
<exception cref="T:System.ArgumentException">
<para>
<paramref name="sourceDirectoryName" /> is <see cref="F:System.String.Empty" />, contains only white space, or contains at least one invalid character.</para>
<para>-or-</para>
<para>The <paramref name="destination" /> stream does not support writing.</para>
</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="sourceDirectoryName" /> or <paramref name="destination" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">In <paramref name="sourceDirectoryName" />, the specified path, file name, or both exceed the system-defined maximum length.</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">
<paramref name="sourceDirectoryName" /> is invalid or does not exist (for example, it is on an unmapped drive).</exception>
<exception cref="T:System.IO.IOException">
<para>A file in the specified directory could not be opened.</para>
<para>-or-</para>
<para>An I/O error occurred while opening a file to be archived.</para>
</exception>
<exception cref="T:System.NotSupportedException">
<paramref name="sourceDirectoryName" /> contains an invalid format.</exception>
<exception cref="T:System.OperationCanceledException">An asynchronous operation is cancelled.</exception>
</Docs>
</Member>
<Member MemberName="CreateFromDirectoryAsync">
<MemberSignature Language="C#" Value="public static System.Threading.Tasks.Task CreateFromDirectoryAsync (string sourceDirectoryName, string destinationArchiveFileName, System.Threading.CancellationToken cancellationToken = default);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Threading.Tasks.Task CreateFromDirectoryAsync(string sourceDirectoryName, string destinationArchiveFileName, valuetype System.Threading.CancellationToken cancellationToken) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.CreateFromDirectoryAsync(System.String,System.String,System.Threading.CancellationToken)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function CreateFromDirectoryAsync (sourceDirectoryName As String, destinationArchiveFileName As String, Optional cancellationToken As CancellationToken = Nothing) As Task" />
<MemberSignature Language="F#" Value="static member CreateFromDirectoryAsync : string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task" Usage="System.IO.Compression.ZipFile.CreateFromDirectoryAsync (sourceDirectoryName, destinationArchiveFileName, cancellationToken)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.Tasks.Task</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sourceDirectoryName" Type="System.String" Index="0" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="destinationArchiveFileName" Type="System.String" Index="1" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="cancellationToken" Type="System.Threading.CancellationToken" Index="2" FrameworkAlternate="net-10.0;net-11.0" />
</Parameters>
<Docs>
<param name="sourceDirectoryName">The path to the directory on the file system to be archived.</param>
<param name="destinationArchiveFileName">The name of the archive to be created.</param>
<param name="cancellationToken">The cancellation token to monitor for cancellation requests.</param>
<summary>
Asynchronously creates a zip archive at the path <paramref name="destinationArchiveFileName" /> that contains the files and directories from the directory specified by <paramref name="sourceDirectoryName" />.
</summary>
<returns>To be added.</returns>
<remarks>
<para>The directory structure is preserved in the archive, and a recursive search is done for files to be archived. The archive must not exist. If the directory is empty, an empty archive is created. If a file in the directory cannot be added to the archive, the archive will be left incomplete and invalid and the method will throw an exception. This method does not include the base directory into the archive.</para>
<para>If an error is encountered while adding files to the archive, this method stops adding files and leaves the archive in an invalid state. The paths are permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. If a file in the archive has data in the last write time field that is not a valid zip timestamp, an indicator value of 1980 January 1 at midnight will be used for the file's last modified time.If an entry with the specified name already exists in the archive, a second entry is created that has an identical name. Since no <code>CompressionLevel</code> is specified, the default provided by the implementation of the underlying compression algorithm is used; the <code>ZipArchive</code> will not impose its own default.</para>
<para>(Currently, the underlying compression algorithm is provided by the <see cref="T:System.IO.Compression.DeflateStream" /> class.)</para>
</remarks>
<exception cref="T:System.ArgumentException">
<para>
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is a zero-length string, contains only whitespace, or contains one or more invalid characters as defined by <code>InvalidPathChars</code>.</para>
</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">
<para>In <paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" />, the specified path, file name, or both exceed the system-defined maximum length.</para>
<para>For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.</para>
</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">
<para>The path specified in <paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is invalid, (for example, it is on an unmapped drive).</para>
<para>-or-</para>
<para>The directory specified by <paramref name="sourceDirectoryName" /> does not exist.</para>
</exception>
<exception cref="T:System.IO.IOException">
<para>
<paramref name="destinationArchiveFileName" /> already exists.</para>
<para>-or-</para>
<para>An I/O error occurred while opening a file to be archived.</para>
</exception>
<exception cref="T:System.UnauthorizedAccessException">
<para>
<paramref name="destinationArchiveFileName" /> specified a directory.</para>
<para>-or-</para>
<para>The caller does not have the required permission.</para>
</exception>
<exception cref="T:System.NotSupportedException">
<para>
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is in an invalid format.</para>
</exception>
<exception cref="T:System.OperationCanceledException">An asynchronous operation is cancelled.</exception>
</Docs>
</Member>
<Member MemberName="CreateFromDirectoryAsync">
<MemberSignature Language="C#" Value="public static System.Threading.Tasks.Task CreateFromDirectoryAsync (string sourceDirectoryName, System.IO.Stream destination, System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory, System.Threading.CancellationToken cancellationToken = default);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Threading.Tasks.Task CreateFromDirectoryAsync(string sourceDirectoryName, class System.IO.Stream destination, valuetype System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory, valuetype System.Threading.CancellationToken cancellationToken) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.CreateFromDirectoryAsync(System.String,System.IO.Stream,System.IO.Compression.CompressionLevel,System.Boolean,System.Threading.CancellationToken)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function CreateFromDirectoryAsync (sourceDirectoryName As String, destination As Stream, compressionLevel As CompressionLevel, includeBaseDirectory As Boolean, Optional cancellationToken As CancellationToken = Nothing) As Task" />
<MemberSignature Language="F#" Value="static member CreateFromDirectoryAsync : string * System.IO.Stream * System.IO.Compression.CompressionLevel * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task" Usage="System.IO.Compression.ZipFile.CreateFromDirectoryAsync (sourceDirectoryName, destination, compressionLevel, includeBaseDirectory, cancellationToken)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.Tasks.Task</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sourceDirectoryName" Type="System.String" Index="0" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="destination" Type="System.IO.Stream" Index="1" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="compressionLevel" Type="System.IO.Compression.CompressionLevel" Index="2" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="includeBaseDirectory" Type="System.Boolean" Index="3" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="cancellationToken" Type="System.Threading.CancellationToken" Index="4" FrameworkAlternate="net-10.0;net-11.0" />
</Parameters>
<Docs>
<param name="sourceDirectoryName">The path to the directory to be archived, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<param name="destination">The stream where the zip archive is to be stored.</param>
<param name="compressionLevel">One of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry.</param>
<param name="includeBaseDirectory">
<see langword="true" /> to include the directory name from <paramref name="sourceDirectoryName" /> at the root of the archive; <see langword="false" /> to include only the contents of the directory.</param>
<param name="cancellationToken">The token to monitor for cancellation requests.</param>
<summary>Asynchronously creates a zip archive in the specified stream that contains the files and directories from the specified directory, using the specified compression level, and optionally including the base directory.</summary>
<returns>To be added.</returns>
<remarks>
<para>The directory structure from the file system is preserved in the archive. If the directory is empty, an empty archive is created.</para>
<para>Use this method overload to specify the compression level and whether to include the base directory in the archive.</para>
<para>If a file in the directory cannot be added to the archive, the archive is left incomplete and invalid, and the method throws an <see cref="T:System.IO.IOException" /> exception.</para>
</remarks>
<exception cref="T:System.ArgumentException">
<para>
<paramref name="sourceDirectoryName" /> is <see cref="F:System.String.Empty" />, contains only white space, or contains at least one invalid character.</para>
<para>-or-</para>
<para>The <paramref name="destination" /> stream does not support writing.</para>
</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="sourceDirectoryName" /> or <paramref name="destination" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">In <paramref name="sourceDirectoryName" />, the specified path, file name, or both exceed the system-defined maximum length.</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">
<paramref name="sourceDirectoryName" /> is invalid or does not exist (for example, it is on an unmapped drive).</exception>
<exception cref="T:System.IO.IOException">
<para>A file in the specified directory could not be opened.</para>
<para>-or-</para>
<para>An I/O error occurred while opening a file to be archived.</para>
</exception>
<exception cref="T:System.NotSupportedException">
<paramref name="sourceDirectoryName" /> contains an invalid format.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="compressionLevel" /> is not a valid <see cref="T:System.IO.Compression.CompressionLevel" /> value.</exception>
<exception cref="T:System.OperationCanceledException">An asynchronous operation is cancelled.</exception>
</Docs>
</Member>
<Member MemberName="CreateFromDirectoryAsync">
<MemberSignature Language="C#" Value="public static System.Threading.Tasks.Task CreateFromDirectoryAsync (string sourceDirectoryName, string destinationArchiveFileName, System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory, System.Threading.CancellationToken cancellationToken = default);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Threading.Tasks.Task CreateFromDirectoryAsync(string sourceDirectoryName, string destinationArchiveFileName, valuetype System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory, valuetype System.Threading.CancellationToken cancellationToken) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.CreateFromDirectoryAsync(System.String,System.String,System.IO.Compression.CompressionLevel,System.Boolean,System.Threading.CancellationToken)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function CreateFromDirectoryAsync (sourceDirectoryName As String, destinationArchiveFileName As String, compressionLevel As CompressionLevel, includeBaseDirectory As Boolean, Optional cancellationToken As CancellationToken = Nothing) As Task" />
<MemberSignature Language="F#" Value="static member CreateFromDirectoryAsync : string * string * System.IO.Compression.CompressionLevel * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task" Usage="System.IO.Compression.ZipFile.CreateFromDirectoryAsync (sourceDirectoryName, destinationArchiveFileName, compressionLevel, includeBaseDirectory, cancellationToken)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.Tasks.Task</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sourceDirectoryName" Type="System.String" Index="0" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="destinationArchiveFileName" Type="System.String" Index="1" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="compressionLevel" Type="System.IO.Compression.CompressionLevel" Index="2" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="includeBaseDirectory" Type="System.Boolean" Index="3" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="cancellationToken" Type="System.Threading.CancellationToken" Index="4" FrameworkAlternate="net-10.0;net-11.0" />
</Parameters>
<Docs>
<param name="sourceDirectoryName">The path to the directory on the file system to be archived.</param>
<param name="destinationArchiveFileName">The name of the archive to be created.</param>
<param name="compressionLevel">One of the enumeration values that specifies the level of the compression (speed/memory vs. compressed size trade-off).</param>
<param name="includeBaseDirectory">
<see langword="true" /> to indicate that a directory named <paramref name="sourceDirectoryName" /> should be included at the root of the archive. <see langword="false" /> to indicate that the files and directories in <paramref name="sourceDirectoryName" /> should be included directly in the archive.
</param>
<param name="cancellationToken">The cancellation token to monitor for cancellation requests.</param>
<summary>
Asynchronously creates a zip archive at the path <paramref name="destinationArchiveFileName" /> that contains the files and directories in the directory specified by <paramref name="sourceDirectoryName" />.
</summary>
<returns>To be added.</returns>
<remarks>
<para>The directory structure is preserved in the archive, and a recursive search is done for files to be archived. The archive must not exist. If the directory is empty, an empty archive will be created.</para>
<para>If a file in the directory cannot be added to the archive, the archive will be left incomplete and invalid and the method will throw an exception. This method optionally includes the base directory in the archive.</para>
<para>If an error is encountered while adding files to the archive, this method will stop adding files and leave the archive in an invalid state. The paths are permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. If a file in the archive has data in the last write time field that is not a valid zip timestamp, an indicator value of 1980 January 1 at midnight will be used for the file's last modified time.If an entry with the specified name already exists in the archive, a second entry will be created that has an identical name. Since no <code>CompressionLevel</code> is specified, the default provided by the implementation of the underlying compression algorithm will be used; the <code>ZipArchive</code> will not impose its own default.</para>
<para>(Currently, the underlying compression algorithm is provided by the <see cref="T:System.IO.Compression.DeflateStream" /> class.)</para>
</remarks>
<exception cref="T:System.ArgumentException">
<para>
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is a zero-length string, contains only whitespace, or contains one or more invalid characters as defined by <code>InvalidPathChars</code>.</para>
</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">
<para>In <paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" />, the specified path, file name, or both exceed the system-defined maximum length.</para>
<para>For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.</para>
</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">
<para>The path specified in <paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is invalid, (for example, it is on an unmapped drive).</para>
<para>-or-</para>
<para>The directory specified by <paramref name="sourceDirectoryName" /> does not exist.</para>
</exception>
<exception cref="T:System.IO.IOException">
<para>
<paramref name="destinationArchiveFileName" /> already exists.</para>
<para>-or-</para>
<para>An I/O error occurred while opening a file to be archived.</para>
</exception>
<exception cref="T:System.UnauthorizedAccessException">
<para>
<paramref name="destinationArchiveFileName" /> specified a directory.</para>
<para>-or-</para>
<para>The caller does not have the required permission.</para>
</exception>
<exception cref="T:System.NotSupportedException">
<para>
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is in an invalid format.</para>
</exception>
<exception cref="T:System.OperationCanceledException">An asynchronous operation is cancelled.</exception>
</Docs>
</Member>
<Member MemberName="CreateFromDirectoryAsync">
<MemberSignature Language="C#" Value="public static System.Threading.Tasks.Task CreateFromDirectoryAsync (string sourceDirectoryName, System.IO.Stream destination, System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory, System.Text.Encoding? entryNameEncoding, System.Threading.CancellationToken cancellationToken = default);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Threading.Tasks.Task CreateFromDirectoryAsync(string sourceDirectoryName, class System.IO.Stream destination, valuetype System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory, class System.Text.Encoding entryNameEncoding, valuetype System.Threading.CancellationToken cancellationToken) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.CreateFromDirectoryAsync(System.String,System.IO.Stream,System.IO.Compression.CompressionLevel,System.Boolean,System.Text.Encoding,System.Threading.CancellationToken)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function CreateFromDirectoryAsync (sourceDirectoryName As String, destination As Stream, compressionLevel As CompressionLevel, includeBaseDirectory As Boolean, entryNameEncoding As Encoding, Optional cancellationToken As CancellationToken = Nothing) As Task" />
<MemberSignature Language="F#" Value="static member CreateFromDirectoryAsync : string * System.IO.Stream * System.IO.Compression.CompressionLevel * bool * System.Text.Encoding * System.Threading.CancellationToken -> System.Threading.Tasks.Task" Usage="System.IO.Compression.ZipFile.CreateFromDirectoryAsync (sourceDirectoryName, destination, compressionLevel, includeBaseDirectory, entryNameEncoding, cancellationToken)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.Tasks.Task</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sourceDirectoryName" Type="System.String" Index="0" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="destination" Type="System.IO.Stream" Index="1" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="compressionLevel" Type="System.IO.Compression.CompressionLevel" Index="2" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="includeBaseDirectory" Type="System.Boolean" Index="3" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="entryNameEncoding" Type="System.Text.Encoding" Index="4" FrameworkAlternate="net-10.0;net-11.0">
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(2)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(2)>]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
<Parameter Name="cancellationToken" Type="System.Threading.CancellationToken" Index="5" FrameworkAlternate="net-10.0;net-11.0" />
</Parameters>
<Docs>
<param name="sourceDirectoryName">The path to the directory to be archived, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<param name="destination">The stream where the zip archive is to be stored.</param>
<param name="compressionLevel">One of the enumeration values that indicates whether to emphasize speed or compression effectiveness when creating the entry.</param>
<param name="includeBaseDirectory">
<see langword="true" /> to include the directory name from <paramref name="sourceDirectoryName" /> at the root of the archive; <see langword="false" /> to include only the contents of the directory.</param>
<param name="entryNameEncoding">The encoding to use when reading or writing entry names in this archive. Specify a value for this parameter only when an encoding is required for interoperability with zip archive tools and libraries that do not support UTF-8 encoding for entry names or comments.</param>
<param name="cancellationToken">The cancellation token to monitor for cancellation requests.</param>
<summary>Asynchronously creates a zip archive in the specified stream that contains the files and directories from the specified directory, using the specified compression level and character encoding for entry names, and optionally including the base directory.</summary>
<returns>To be added.</returns>
<remarks>
<para>The directory structure from the file system is preserved in the archive. If the directory is empty, an empty archive is created.</para>
<para>Use this method overload to specify the compression level and character encoding, and whether to include the base directory in the archive.</para>
<para>If a file in the directory cannot be added to the archive, the archive is left incomplete and invalid, and the method throws an <see cref="T:System.IO.IOException" /> exception.</para>
</remarks>
<exception cref="T:System.ArgumentException">
<para>
<paramref name="sourceDirectoryName" /> is <see cref="F:System.String.Empty" />, contains only white space, or contains at least one invalid character.</para>
<para>-or-</para>
<para>The <paramref name="destination" /> stream does not support writing.</para>
</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="sourceDirectoryName" /> or <paramref name="destination" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">In <paramref name="sourceDirectoryName" />, the specified path, file name, or both exceed the system-defined maximum length.</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">
<paramref name="sourceDirectoryName" /> is invalid or does not exist (for example, it is on an unmapped drive).</exception>
<exception cref="T:System.IO.IOException">
<para>A file in the specified directory could not be opened.</para>
<para>-or-</para>
<para>An I/O error occurred while opening a file to be archived.</para>
</exception>
<exception cref="T:System.NotSupportedException">
<paramref name="sourceDirectoryName" /> contains an invalid format.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<paramref name="compressionLevel" /> is not a valid <see cref="T:System.IO.Compression.CompressionLevel" /> value.</exception>
<exception cref="T:System.OperationCanceledException">An asynchronous operation is cancelled.</exception>
</Docs>
</Member>
<Member MemberName="CreateFromDirectoryAsync">
<MemberSignature Language="C#" Value="public static System.Threading.Tasks.Task CreateFromDirectoryAsync (string sourceDirectoryName, string destinationArchiveFileName, System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory, System.Text.Encoding? entryNameEncoding, System.Threading.CancellationToken cancellationToken = default);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Threading.Tasks.Task CreateFromDirectoryAsync(string sourceDirectoryName, string destinationArchiveFileName, valuetype System.IO.Compression.CompressionLevel compressionLevel, bool includeBaseDirectory, class System.Text.Encoding entryNameEncoding, valuetype System.Threading.CancellationToken cancellationToken) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.CreateFromDirectoryAsync(System.String,System.String,System.IO.Compression.CompressionLevel,System.Boolean,System.Text.Encoding,System.Threading.CancellationToken)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function CreateFromDirectoryAsync (sourceDirectoryName As String, destinationArchiveFileName As String, compressionLevel As CompressionLevel, includeBaseDirectory As Boolean, entryNameEncoding As Encoding, Optional cancellationToken As CancellationToken = Nothing) As Task" />
<MemberSignature Language="F#" Value="static member CreateFromDirectoryAsync : string * string * System.IO.Compression.CompressionLevel * bool * System.Text.Encoding * System.Threading.CancellationToken -> System.Threading.Tasks.Task" Usage="System.IO.Compression.ZipFile.CreateFromDirectoryAsync (sourceDirectoryName, destinationArchiveFileName, compressionLevel, includeBaseDirectory, entryNameEncoding, cancellationToken)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
<AssemblyVersion>11.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.Tasks.Task</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sourceDirectoryName" Type="System.String" Index="0" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="destinationArchiveFileName" Type="System.String" Index="1" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="compressionLevel" Type="System.IO.Compression.CompressionLevel" Index="2" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="includeBaseDirectory" Type="System.Boolean" Index="3" FrameworkAlternate="net-10.0;net-11.0" />
<Parameter Name="entryNameEncoding" Type="System.Text.Encoding" Index="4" FrameworkAlternate="net-10.0;net-11.0">
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(2)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(2)>]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
<Parameter Name="cancellationToken" Type="System.Threading.CancellationToken" Index="5" FrameworkAlternate="net-10.0;net-11.0" />
</Parameters>
<Docs>
<param name="sourceDirectoryName">The path to the directory on the file system to be archived.</param>
<param name="destinationArchiveFileName">The name of the archive to be created.</param>
<param name="compressionLevel">One of the enumeration values that specifies the level of the compression (speed/memory vs. compressed size trade-off).</param>
<param name="includeBaseDirectory">
<para>
<see langword="true" /> to indicate that a directory named <paramref name="sourceDirectoryName" /> should be included at the root of the archive. <see langword="false" /> to indicate that the files and directories in <paramref name="sourceDirectoryName" /> should be included directly in the archive.</para>
</param>
<param name="entryNameEncoding">
The encoding to use when reading or writing entry names and comments in this ZipArchive.
</param>
<param name="cancellationToken">The cancellation token to monitor for cancellation requests.</param>
<summary>
Asynchronously creates a zip archive at the path <paramref name="destinationArchiveFileName" /> that contains the files and directories in the directory specified by <paramref name="sourceDirectoryName" />.
</summary>
<returns>To be added.</returns>
<remarks>
<para>The directory structure is preserved in the archive, and a recursive search is done for files to be archived. The archive must not exist. If the directory is empty, an empty archive will be created.</para>
<para>If a file in the directory cannot be added to the archive, the archive will be left incomplete and invalid and the method will throw an exception. This method optionally includes the base directory in the archive.</para>
<para>If an error is encountered while adding files to the archive, this method will stop adding files and leave the archive in an invalid state. The paths are permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. If a file in the archive has data in the last write time field that is not a valid zip timestamp, an indicator value of 1980 January 1 at midnight will be used for the file's last modified time.If an entry with the specified name already exists in the archive, a second entry will be created that has an identical name. Since no <code>CompressionLevel</code> is specified, the default provided by the implementation of the underlying compression algorithm will be used; the <code>ZipArchive</code> will not impose its own default.</para>
<para>(Currently, the underlying compression algorithm is provided by the <see cref="T:System.IO.Compression.DeflateStream" /> class.)</para>
<para>Specifying a value for <paramref name="entryNameEncoding" /> other than <see langword="null" /> is discouraged.</para>
<para>However, this may be necessary for interoperability with zip archive tools and libraries that do not correctly support UTF-8 encoding for entry names or comments.</para>
<ul>
<li>If <paramref name="entryNameEncoding" /> is not specified (<code>== null</code>):
<ul><li>For file names or comments that contain characters outside the ASCII range:
<br />The language encoding flag (EFS) will be set in the general purpose bit flag of the local file header of the corresponding entry, and UTF-8 (<code>Encoding.UTF8</code>) will be used to encode the entry name and comment into bytes.</li><li>For file names or comments that do not contain characters outside the ASCII range:
<br />The language encoding flag (EFS) will not be set in the general purpose bit flag of the local file header of the corresponding entry, and the current system default code page (<code>Encoding.Default</code>) will be used to encode the entry names and comments into bytes.</li></ul></li>
<li>If <paramref name="entryNameEncoding" /> is specified (<code>!= null</code>):
<ul><li>The specified <paramref name="entryNameEncoding" /> will always be used to encode the entry names and comments into bytes.
<br />The language encoding flag (EFS) in the general purpose bit flag of the local file header for each entry will be set if and only if the specified <paramref name="entryNameEncoding" /> is a UTF-8 encoding.</li></ul></li>
</ul>
<para>Unicode encodings other than UTF-8 can't be used for the <paramref name="entryNameEncoding" />, otherwise an <see cref="T:System.ArgumentException" /> is thrown.</para>
</remarks>
<exception cref="T:System.ArgumentException">
<para>
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is a zero-length string, contains only whitespace, or contains one or more invalid characters as defined by <code>InvalidPathChars</code>.</para>
</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">
<para>In <paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" />, the specified path, file name, or both exceed the system-defined maximum length.</para>
<para>For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.</para>
</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">
<para>The path specified in <paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is invalid, (for example, it is on an unmapped drive).</para>
<para>-or-</para>
<para>The directory specified by <paramref name="sourceDirectoryName" /> does not exist.</para>
</exception>
<exception cref="T:System.IO.IOException">
<para>
<paramref name="destinationArchiveFileName" /> already exists.</para>
<para>-or-</para>
<para>An I/O error occurred while opening a file to be archived.</para>
</exception>
<exception cref="T:System.UnauthorizedAccessException">
<para>
<paramref name="destinationArchiveFileName" /> specified a directory.</para>
<para>-or-</para>
<para>The caller does not have the required permission.</para>
</exception>
<exception cref="T:System.NotSupportedException">
<para>
<paramref name="sourceDirectoryName" /> or <paramref name="destinationArchiveFileName" /> is in an invalid format.</para>
</exception>
<exception cref="T:System.OperationCanceledException">An asynchronous operation is cancelled.</exception>
</Docs>
</Member>
<MemberGroup MemberName="ExtractToDirectory">
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>4.0.1.0</AssemblyVersion>