-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
ZipFile.xml
1534 lines (1331 loc) · 116 KB
/
ZipFile.xml
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>
</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="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-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(0)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(0)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.NullableContext(1)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.NullableContext(1)>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Provides static methods for creating, extracting, and opening zip archives.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
[!INCLUDE[remarks](~/includes/remarks/System.IO.Compression/ZipFile/ZipFile.md)]
]]></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>
</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" />
<Parameter Name="destination" Type="System.IO.Stream" Index="1" FrameworkAlternate="net-8.0;net-9.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>
</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/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/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>
</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" />
<Parameter Name="destination" Type="System.IO.Stream" Index="1" FrameworkAlternate="net-8.0;net-9.0" />
<Parameter Name="compressionLevel" Type="System.IO.Compression.CompressionLevel" Index="2" FrameworkAlternate="net-8.0;net-9.0" />
<Parameter Name="includeBaseDirectory" Type="System.Boolean" Index="3" FrameworkAlternate="net-8.0;net-9.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>
</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/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/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>
</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" />
<Parameter Name="destination" Type="System.IO.Stream" Index="1" FrameworkAlternate="net-8.0;net-9.0" />
<Parameter Name="compressionLevel" Type="System.IO.Compression.CompressionLevel" Index="2" FrameworkAlternate="net-8.0;net-9.0" />
<Parameter Name="includeBaseDirectory" Type="System.Boolean" Index="3" FrameworkAlternate="net-8.0;net-9.0" />
<Parameter Name="entryNameEncoding" Type="System.Text.Encoding" Index="4" FrameworkAlternate="net-8.0;net-9.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 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.</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 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-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>
</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-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 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.</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 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 are encoded by using the specified encoding. If the specified encoding is a UTF-8, 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 are encoded according to the following rules:
- For entry names that contain characters outside the ASCII range, the language encoding flag is set, and UTF-8 is used to encode the entry name.
- For entry names that contain only ASCII characters, the language encoding flag is set, and the current system default code page is used to encode the entry names.
]]></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>
<MemberGroup MemberName="ExtractToDirectory">
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.3.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Extracts all the files in the specified zip archive to a directory on the file system.</summary>
</Docs>
</MemberGroup>
<Member MemberName="ExtractToDirectory">
<MemberSignature Language="C#" Value="public static void ExtractToDirectory (System.IO.Stream source, string destinationDirectoryName);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void ExtractToDirectory(class System.IO.Stream source, string destinationDirectoryName) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.ExtractToDirectory(System.IO.Stream,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub ExtractToDirectory (source As Stream, destinationDirectoryName As String)" />
<MemberSignature Language="F#" Value="static member ExtractToDirectory : System.IO.Stream * string -> unit" Usage="System.IO.Compression.ZipFile.ExtractToDirectory (source, destinationDirectoryName)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void ExtractToDirectory(System::IO::Stream ^ source, System::String ^ destinationDirectoryName);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="source" Type="System.IO.Stream" Index="0" FrameworkAlternate="net-8.0;net-9.0" />
<Parameter Name="destinationDirectoryName" Type="System.String" Index="1" FrameworkAlternate="net-8.0;net-9.0" />
</Parameters>
<Docs>
<param name="source">The stream from which the zip archive is to be extracted.</param>
<param name="destinationDirectoryName">The path to the directory in which to place the extracted files, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<summary>Extracts all the files from the zip archive stored in the specified stream and places them in the specified destination directory on the file system.</summary>
<remarks>This method creates the specified directory and all subdirectories. The destination directory cannot already exist.
Exceptions related to validating the paths in the <paramref name="destinationDirectoryName" /> or the files in the zip archive contained in <paramref name="source" /> parameters are thrown before extraction. Otherwise, if an error occurs during extraction, the archive remains partially extracted.
Each extracted file has the same relative path to the directory specified by <paramref name="destinationDirectoryName" /> as its source entry has to the root of the archive.
If a file to be archived has an invalid last modified time, the first date and time representable in the Zip timestamp format (midnight on January 1, 1980) will be used.</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="destinationDirectoryName" />> 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="destinationDirectoryName" /> or <paramref name="source" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">The specified path in <paramref name="destinationDirectoryName" /> exceeds the system-defined maximum length.</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive).</exception>
<exception cref="T:System.IO.IOException">The name of an entry in the archive is <see cref="F:System.String.Empty" />, contains only white space, or contains at least one invalid character.
-or-
Extracting an archive entry would create a file that is outside the directory specified by <paramref name="destinationDirectoryName" />. (For example, this might happen if the entry name contains parent directory accessors.)
-or-
An archive entry to extract has the same name as an entry that has already been extracted or that exists in <paramref name="destinationDirectoryName" />.</exception>
<exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission to access the archive or the destination directory.</exception>
<exception cref="T:System.NotSupportedException">
<paramref name="destinationDirectoryName" /> contains an invalid format.</exception>
<exception cref="T:System.IO.InvalidDataException">The archive contained in the <paramref name="source" /> stream is not a valid zip archive.
-or-
An archive entry was not found or was corrupt.
-or-
An archive entry was compressed by using a compression method that is not supported.</exception>
</Docs>
</Member>
<Member MemberName="ExtractToDirectory">
<MemberSignature Language="C#" Value="public static void ExtractToDirectory (string sourceArchiveFileName, string destinationDirectoryName);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.ExtractToDirectory(System.String,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub ExtractToDirectory (sourceArchiveFileName As String, destinationDirectoryName As String)" />
<MemberSignature Language="F#" Value="static member ExtractToDirectory : string * string -> unit" Usage="System.IO.Compression.ZipFile.ExtractToDirectory (sourceArchiveFileName, destinationDirectoryName)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void ExtractToDirectory(System::String ^ sourceArchiveFileName, System::String ^ destinationDirectoryName);" />
<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>
</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="sourceArchiveFileName" Type="System.String" />
<Parameter Name="destinationDirectoryName" Type="System.String" />
</Parameters>
<Docs>
<param name="sourceArchiveFileName">The path to the archive that is to be extracted.</param>
<param name="destinationDirectoryName">The path to the directory in which to place the extracted files, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<summary>Extracts all the files in the specified zip archive to a directory on the file system.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method creates the specified directory and all subdirectories. The destination directory cannot already exist. Exceptions related to validating the paths in the `destinationDirectoryName` or `sourceArchiveFileName` parameters are thrown before extraction. Otherwise, if an error occurs during extraction, the archive remains partially extracted. Each extracted file has the same relative path to the directory specified by `destinationDirectoryName` as its source entry has to the root of the archive.
## 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 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/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/program1.vb" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="destinationDirectoryName" /> or <paramref name="sourceArchiveFileName" /> 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="destinationDirectoryName" /> or <paramref name="sourceArchiveFileName" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">The specified path in <paramref name="destinationDirectoryName" /> or <paramref name="sourceArchiveFileName" /> exceeds the system-defined maximum length.</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive).</exception>
<exception cref="T:System.IO.IOException">The name of an entry in the archive is <see cref="F:System.String.Empty" />, contains only white space, or contains at least one invalid character.
-or-
Extracting an archive entry would create a file that is outside the directory specified by <paramref name="destinationDirectoryName" />. (For example, this might happen if the entry name contains parent directory accessors.)
-or-
An archive entry to extract has the same name as an entry that has already been extracted or that exists in <paramref name="destinationDirectoryName" />.</exception>
<exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission to access the archive or the destination directory.</exception>
<exception cref="T:System.NotSupportedException">
<paramref name="destinationDirectoryName" /> or <paramref name="sourceArchiveFileName" /> contains an invalid format.</exception>
<exception cref="T:System.IO.FileNotFoundException">
<paramref name="sourceArchiveFileName" /> was not found.</exception>
<exception cref="T:System.IO.InvalidDataException">The archive specified by <paramref name="sourceArchiveFileName" /> is not a valid zip archive.
-or-
An archive entry was not found or was corrupt.
-or-
An archive entry was compressed by using a compression method that is not supported.</exception>
</Docs>
</Member>
<Member MemberName="ExtractToDirectory">
<MemberSignature Language="C#" Value="public static void ExtractToDirectory (System.IO.Stream source, string destinationDirectoryName, bool overwriteFiles);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void ExtractToDirectory(class System.IO.Stream source, string destinationDirectoryName, bool overwriteFiles) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.ExtractToDirectory(System.IO.Stream,System.String,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub ExtractToDirectory (source As Stream, destinationDirectoryName As String, overwriteFiles As Boolean)" />
<MemberSignature Language="F#" Value="static member ExtractToDirectory : System.IO.Stream * string * bool -> unit" Usage="System.IO.Compression.ZipFile.ExtractToDirectory (source, destinationDirectoryName, overwriteFiles)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void ExtractToDirectory(System::IO::Stream ^ source, System::String ^ destinationDirectoryName, bool overwriteFiles);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="source" Type="System.IO.Stream" Index="0" FrameworkAlternate="net-8.0;net-9.0" />
<Parameter Name="destinationDirectoryName" Type="System.String" Index="1" FrameworkAlternate="net-8.0;net-9.0" />
<Parameter Name="overwriteFiles" Type="System.Boolean" Index="2" FrameworkAlternate="net-8.0;net-9.0" />
</Parameters>
<Docs>
<param name="source">The stream from which the zip archive is to be extracted.</param>
<param name="destinationDirectoryName">The path to the directory in which to place the extracted files, specified as a relative or absolute path. A relative path is interpreted as relative to the current working directory.</param>
<param name="overwriteFiles">
<see langword="true" /> to overwrite files; <see langword="false" /> otherwise.</param>
<summary>Extracts all the files from the zip archive stored in the specified stream and places them in the specified destination directory on the file system, and optionally allows choosing if the files in the destination directory should be overwritten.</summary>
<remarks>This method creates the specified directory and all subdirectories. The destination directory cannot already exist.
Exceptions related to validating the paths in the <paramref name="destinationDirectoryName" /> or the files in the zip archive contained in <paramref name="source" /> parameters are thrown before extraction. Otherwise, if an error occurs during extraction, the archive remains partially extracted.
Each extracted file has the same relative path to the directory specified by <paramref name="destinationDirectoryName" /> as its source entry has to the root of the archive.
If a file to be archived has an invalid last modified time, the first date and time representable in the Zip timestamp format (midnight on January 1, 1980) will be used.</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="destinationDirectoryName" />> 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="destinationDirectoryName" /> or <paramref name="source" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">The specified path in <paramref name="destinationDirectoryName" /> exceeds the system-defined maximum length.</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive).</exception>
<exception cref="T:System.IO.IOException">The name of an entry in the archive is <see cref="F:System.String.Empty" />, contains only white space, or contains at least one invalid character.
-or-
Extracting an archive entry would create a file that is outside the directory specified by <paramref name="destinationDirectoryName" />. (For example, this might happen if the entry name contains parent directory accessors.)
-or-
<paramref name="overwriteFiles" /> is <see langword="false" /> and an archive entry to extract has the same name as an entry that has already been extracted or that exists in <paramref name="destinationDirectoryName" />.</exception>
<exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission to access the archive or the destination directory.</exception>
<exception cref="T:System.NotSupportedException">
<paramref name="destinationDirectoryName" /> contains an invalid format.</exception>
<exception cref="T:System.IO.InvalidDataException">The archive contained in the <paramref name="source" /> stream is not a valid zip archive.
-or-
An archive entry was not found or was corrupt.
-or-
An archive entry was compressed by using a compression method that is not supported.</exception>
</Docs>
</Member>
<Member MemberName="ExtractToDirectory">
<MemberSignature Language="C#" Value="public static void ExtractToDirectory (System.IO.Stream source, string destinationDirectoryName, System.Text.Encoding? entryNameEncoding);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void ExtractToDirectory(class System.IO.Stream source, string destinationDirectoryName, class System.Text.Encoding entryNameEncoding) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.ExtractToDirectory(System.IO.Stream,System.String,System.Text.Encoding)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub ExtractToDirectory (source As Stream, destinationDirectoryName As String, entryNameEncoding As Encoding)" />
<MemberSignature Language="F#" Value="static member ExtractToDirectory : System.IO.Stream * string * System.Text.Encoding -> unit" Usage="System.IO.Compression.ZipFile.ExtractToDirectory (source, destinationDirectoryName, entryNameEncoding)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void ExtractToDirectory(System::IO::Stream ^ source, System::String ^ destinationDirectoryName, 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>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="source" Type="System.IO.Stream" Index="0" FrameworkAlternate="net-8.0;net-9.0" />
<Parameter Name="destinationDirectoryName" Type="System.String" Index="1" FrameworkAlternate="net-8.0;net-9.0" />
<Parameter Name="entryNameEncoding" Type="System.Text.Encoding" Index="2" FrameworkAlternate="net-8.0;net-9.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="source">The stream from which the zip archive is to be extracted.</param>
<param name="destinationDirectoryName">The path to the directory in which to place the extracted files, specified as a relative or absolute path. A relative path is interpreted as relative to the current working 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.</param>
<summary>Extracts all the files from the zip archive stored in the specified stream and places them in the specified destination directory on the file system and uses the specified character encoding for entry names.</summary>
<remarks>This method creates the specified directory and all subdirectories. The destination directory cannot already exist.
Exceptions related to validating the paths in the <paramref name="destinationDirectoryName" /> or the files in the zip archive contained in <paramref name="source" /> parameters are thrown before extraction. Otherwise, if an error occurs during extraction, the archive remains partially extracted.
Each extracted file has the same relative path to the directory specified by <paramref name="destinationDirectoryName" /> as its source entry has to the root of the archive.
If a file to be archived has an invalid last modified time, the first date and time representable in the Zip timestamp format (midnight on January 1, 1980) will be used.</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="destinationDirectoryName" />> 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="destinationDirectoryName" /> or <paramref name="source" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">The specified path in <paramref name="destinationDirectoryName" /> exceeds the system-defined maximum length.</exception>
<exception cref="T:System.IO.DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive).</exception>
<exception cref="T:System.IO.IOException">The name of an entry in the archive is <see cref="F:System.String.Empty" />, contains only white space, or contains at least one invalid character.
-or-
Extracting an archive entry would create a file that is outside the directory specified by <paramref name="destinationDirectoryName" />. (For example, this might happen if the entry name contains parent directory accessors.)
-or-
An archive entry to extract has the same name as an entry that has already been extracted or that exists in <paramref name="destinationDirectoryName" />.</exception>
<exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission to access the archive or the destination directory.</exception>
<exception cref="T:System.NotSupportedException">
<paramref name="destinationDirectoryName" /> contains an invalid format.</exception>
<exception cref="T:System.IO.InvalidDataException">The archive contained in the <paramref name="source" /> stream is not a valid zip archive.
-or-
An archive entry was not found or was corrupt.
-or-
An archive entry was compressed by using a compression method that is not supported.</exception>
</Docs>
</Member>
<Member MemberName="ExtractToDirectory">
<MemberSignature Language="C#" Value="public static void ExtractToDirectory (string sourceArchiveFileName, string destinationDirectoryName, bool overwriteFiles);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName, bool overwriteFiles) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.ExtractToDirectory(System.String,System.String,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub ExtractToDirectory (sourceArchiveFileName As String, destinationDirectoryName As String, overwriteFiles As Boolean)" />
<MemberSignature Language="F#" Value="static member ExtractToDirectory : string * string * bool -> unit" Usage="System.IO.Compression.ZipFile.ExtractToDirectory (sourceArchiveFileName, destinationDirectoryName, overwriteFiles)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void ExtractToDirectory(System::String ^ sourceArchiveFileName, System::String ^ destinationDirectoryName, bool overwriteFiles);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.ZipFile</AssemblyName>
<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>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.IO.Compression.FileSystem</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sourceArchiveFileName" Type="System.String" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netstandard-2.1;netcore-3.1;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<Parameter Name="destinationDirectoryName" Type="System.String" Index="1" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netstandard-2.1;netcore-3.1;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<Parameter Name="overwriteFiles" Type="System.Boolean" Index="2" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netstandard-2.1;netcore-3.1;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
</Parameters>
<Docs>
<param name="sourceArchiveFileName">The path on the file system to the archive that is to be extracted.</param>
<param name="destinationDirectoryName">The path to the destination directory on the file system.</param>
<param name="overwriteFiles">
<see langword="true" /> to overwrite files; <see langword="false" /> otherwise.</param>
<summary>Extracts all of the files in the specified archive to a directory on the file system.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If there is an error while extracting the archive, the archive will remain partially extracted.
Each entry will be extracted such that the extracted file has the same relative path to the `destinationDirectoryName` as the entry has to the archive.
The `sourceArchiveFileName` and `destinationDirectoryName` parameters accept both relative and absolute paths. A relative path is interpreted as relative to the current working directory.
If a file to be archived has an invalid last modified time, the first date and time representable in the Zip timestamp format (midnight on January 1, 1980) will be used.
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="sourceArchiveFileName" /> or <paramref name="destinationDirectoryName" /> is a zero-length string, contains only whitespace, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="sourceArchiveFileName" /> or <paramref name="destinationDirectoryName" /> is <see langword="null" />.</exception>
<exception cref="T:System.IO.PathTooLongException">
<paramref name="sourceArchiveFileName" /> or <paramref name="destinationDirectoryName" /> specifies a path, a file name, or both that exceed the system-defined maximum length. </exception>
<exception cref="T:System.IO.DirectoryNotFoundException">The path specified by <paramref name="sourceArchiveFileName" /> or <paramref name="destinationDirectoryName" /> is invalid (for example, it is on an unmapped drive).</exception>
<exception cref="T:System.IO.IOException">
<paramref name="overwriteFiles" /> is <see langword="false" /> and <paramref name="destinationDirectoryName" /> already contains a file with the same name as a file that's being extracted.
-or-
An I/O error has occurred.
-or-
The name of a <see cref="T:System.IO.Compression.ZipArchiveEntry" /> is zero-length, contains only whitespace, or contains one or more invalid characters as defined by <see cref="F:System.IO.Path.InvalidPathChars" />.
-or-
Extracting a <see cref="T:System.IO.Compression.ZipArchiveEntry" /> would result in a file destination that is outside the destination directory (for example, because of parent directory accessors).
-or-
A <see cref="T:System.IO.Compression.ZipArchiveEntry" /> has the same name as an entry from the same archive that's already been extracted.</exception>
<exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.</exception>
<exception cref="T:System.NotSupportedException">
<paramref name="sourceArchiveFileName" /> or <paramref name="destinationDirectoryName" /> is in an invalid format. </exception>
<exception cref="T:System.IO.FileNotFoundException">
<paramref name="sourceArchiveFileName" /> was not found.
</exception>
<exception cref="T:System.IO.InvalidDataException">The archive specified by <paramref name="sourceArchiveFileName" /> is not a valid <see cref="T:System.IO.Compression.ZipArchive" />.
-or-
A <see cref="T:System.IO.Compression.ZipArchiveEntry" /> was not found or was corrupt.
-or-
A <see cref="T:System.IO.Compression.ZipArchiveEntry" /> has been compressed using a compression method that is not supported.</exception>
</Docs>
</Member>
<Member MemberName="ExtractToDirectory">
<MemberSignature Language="C#" Value="public static void ExtractToDirectory (string sourceArchiveFileName, string destinationDirectoryName, 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 ExtractToDirectory(string sourceArchiveFileName, string destinationDirectoryName, class System.Text.Encoding entryNameEncoding) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Compression.ZipFile.ExtractToDirectory(System.String,System.String,System.Text.Encoding)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub ExtractToDirectory (sourceArchiveFileName As String, destinationDirectoryName As String, entryNameEncoding As Encoding)" />
<MemberSignature Language="F#" Value="static member ExtractToDirectory : string * string * System.Text.Encoding -> unit" Usage="System.IO.Compression.ZipFile.ExtractToDirectory (sourceArchiveFileName, destinationDirectoryName, entryNameEncoding)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void ExtractToDirectory(System::String ^ sourceArchiveFileName, System::String ^ destinationDirectoryName, System::Text::Encoding ^ entryNameEncoding);" />
<MemberSignature Language="C#" Value="public static void ExtractToDirectory (string sourceArchiveFileName, string destinationDirectoryName, System.Text.Encoding? entryNameEncoding);" FrameworkAlternate="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>
</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="sourceArchiveFileName" Type="System.String" />
<Parameter Name="destinationDirectoryName" Type="System.String" />
<Parameter Name="entryNameEncoding" Type="System.Text.Encoding">
<Attributes>
<Attribute FrameworkAlternate="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="sourceArchiveFileName">The path to the archive that is to be extracted.</param>
<param name="destinationDirectoryName">The path to the directory in which to place the extracted files, specified as a relative or absolute path. A relative path is interpreted as relative to the current working 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.</param>
<summary>Extracts all the files in the specified zip archive to a directory on the file system and uses the specified character encoding for entry names.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method creates the specified directory and all subdirectories, if necessary. Exceptions related to validating the paths in the `destinationDirectoryName` or `sourceArchiveFileName` parameters are thrown before extraction. Otherwise, if an error occurs during extraction, the archive remains partially extracted. Each extracted file has the same relative path to the directory specified by `destinationDirectoryName` as its source entry has to the root of the archive.
If `entryNameEncoding` is set to a value other than `null`, entry names are decoded according to the following rules:
- For entry names where the language encoding flag (in the general-purpose bit flag of the local file header) is not set, the entry names are decoded by using the specified encoding.