-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Package.xml
2127 lines (1930 loc) · 147 KB
/
Package.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="Package" FullName="System.IO.Packaging.Package">
<TypeSignature Language="C#" Value="public abstract class Package : IDisposable" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract beforefieldinit Package extends System.Object implements class System.IDisposable" />
<TypeSignature Language="DocId" Value="T:System.IO.Packaging.Package" />
<TypeSignature Language="VB.NET" Value="Public MustInherit Class Package
Implements IDisposable" />
<TypeSignature Language="F#" Value="type Package = class
 interface IDisposable" />
<TypeSignature Language="C++ CLI" Value="public ref class Package abstract : IDisposable" />
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.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>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeForwardingChain>
<TypeForwarding From="System.IO.Packaging" FromVersion="9.0.0.0" To="WindowsBase" ToVersion="4.0.0.0" FrameworkAlternate="netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1" />
<TypeForwarding From="WindowsBase" FromVersion="4.0.0.0" To="System.IO.Packaging" ToVersion="4.0.4.0" FrameworkAlternate="windowsdesktop-3.0" />
<TypeForwarding From="WindowsBase" FromVersion="4.0.0.0" To="System.IO.Packaging" ToVersion="4.0.5.0" FrameworkAlternate="windowsdesktop-3.1" />
<TypeForwarding From="WindowsBase" FromVersion="5.0.0.0" To="System.IO.Packaging" ToVersion="5.0.0.0" FrameworkAlternate="windowsdesktop-5.0" />
<TypeForwarding From="WindowsBase" FromVersion="6.0.0.0" To="System.IO.Packaging" ToVersion="6.0.0.0" FrameworkAlternate="windowsdesktop-6.0" />
<TypeForwarding From="WindowsBase" FromVersion="7.0.0.0" To="System.IO.Packaging" ToVersion="7.0.0.0" FrameworkAlternate="windowsdesktop-7.0" />
<TypeForwarding From="WindowsBase" FromVersion="8.0.0.0" To="System.IO.Packaging" ToVersion="8.0.0.0" FrameworkAlternate="windowsdesktop-8.0" />
<TypeForwarding From="WindowsBase" FromVersion="9.0.0.0" To="System.IO.Packaging" ToVersion="9.0.0.0" FrameworkAlternate="windowsdesktop-9.0" />
</TypeForwardingChain>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces>
<Interface FrameworkAlternate="windowsdesktop-9.0">
<InterfaceName>System.IDisposable</InterfaceName>
</Interface>
</Interfaces>
<Attributes>
<Attribute FrameworkAlternate="net-8.0;net-9.0;windowsdesktop-8.0;windowsdesktop-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;windowsdesktop-8.0;windowsdesktop-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.NullableContext(1)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.NullableContext(1)>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Represents a container that can store multiple data objects.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.IO.Packaging.Package> is an abstract class that can be used to organize objects into a single entity of a defined physical format for portability and efficient access.
A ZIP file is the primary physical format for the <xref:System.IO.Packaging.Package>. Other <xref:System.IO.Packaging.Package> implementations might use other physical formats such as an XML document, a database, or Web service.
Like a file system, items contained in a <xref:System.IO.Packaging.Package> are referenced in a hierarchical organization of folders and files.
Although <xref:System.IO.Packaging.Package> itself is an abstract class, the <xref:System.IO.Packaging.ZipPackage> derived class is used as default by the <xref:System.IO.Packaging.Package.Open%2A> method.
A <xref:System.IO.Packaging.PackagePart> ("part") is the abstract class that represents an object that is stored in a <xref:System.IO.Packaging.Package>.
A <xref:System.IO.Packaging.PackageRelationship> ("relationship") defines an association between a source <xref:System.IO.Packaging.Package> or <xref:System.IO.Packaging.PackagePart> and a target object. A <xref:System.IO.Packaging.PackageRelationship> can be one of two types, each of which can be one of two forms:
- A package-level relationship (created by the <xref:System.IO.Packaging.Package.CreateRelationship%2A?displayProperty=nameWithType> method) relates a <xref:System.IO.Packaging.Package> to either:
- A target part in the package.
- A target resource outside the package.
- A part-level relationship (created by the <xref:System.IO.Packaging.PackagePart.CreateRelationship%2A?displayProperty=nameWithType> method) relates a source <xref:System.IO.Packaging.PackagePart> to either:
- Another target part in the package.
- A target resource outside the package.
The relationship's source <xref:System.IO.Packaging.Package> or source <xref:System.IO.Packaging.PackagePart> is considered the "owner" of the relationship. When the source object is deleted, all the relationships owned by the source object are also deleted. The process of creating or deleting a relationship does not physically change either the source or target objects in any way.
A <xref:System.IO.Packaging.PackageDigitalSignature> ("digital signature") is a composition of parts and relationships representing a digital signature included with a <xref:System.IO.Packaging.Package>. The digital signature identifies the originator and validates that the signed parts and relationships contained in the <xref:System.IO.Packaging.Package> have not been modified.
Packages also support Digital Rights Management (DRM) which allows content elements in a <xref:System.IO.Packaging.Package> to be encrypted with specific access rights granted to authorized users.
Based on the <xref:System.IO.Packaging.Package> architecture, an <xref:System.Windows.Xps.Packaging.XpsDocument> is a package type designed for storing documents based on the open [XML Paper Specification (XPS)](https://www.ecma-international.org/publications-and-standards/standards/ecma-388/).
.NET Framework uses packages to store content, resources, and relationships for pages and documents using a standard ZIP file by default. As with any ZIP file, your application can use the <xref:System.IO.Packaging> classes to store and optionally protect any type or number of data files in a single efficient-to-access container.
For more information, see the Open Packaging Conventions (OPC) specification available for download at <https://www.ecma-international.org/publications-and-standards/standards/ecma-376/>.
## Examples
The following example shows the basic steps for creating a <xref:System.IO.Packaging.Package>. In this example, a package is created to contain a document together with a graphic image that is displayed as part of the document. (This is similar to the case in which an HTML file has an \<IMG> tag that references an external image file.) Two <xref:System.IO.Packaging.PackageRelationship> elements are also included in the package. The first, a "package-level" relationship, defines the document part as the package's root element. A second, "part-level" relationship defines the association between the document part (the "source" of the part-level relationship) and its use of the image part (the "target" of the part-level relationship).
:::code language="csharp" source="~/snippets/csharp/System.IO.Packaging/Package/Overview/PackageWrite.cs" id="Snippetpackagewritecreatepackage":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/PackageWrite/visualbasic/packagewrite.vb" id="Snippetpackagewritecreatepackage":::
]]></format>
</remarks>
<altmember cref="T:System.IO.Packaging.PackagePart" />
<altmember cref="T:System.Windows.Xps.Packaging.XpsDocument" />
<related type="ExternalDocumentation" href="https://www.ecma-international.org/publications-and-standards/standards/ecma-376/">Open Packaging Conventions (OPC) Specification</related>
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.IO.Packaging.Package" /> class.</summary>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="protected Package (System.IO.FileAccess openFileAccess);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig specialname rtspecialname instance void .ctor(valuetype System.IO.FileAccess openFileAccess) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Packaging.Package.#ctor(System.IO.FileAccess)" />
<MemberSignature Language="VB.NET" Value="Protected Sub New (openFileAccess As FileAccess)" />
<MemberSignature Language="F#" Value="new System.IO.Packaging.Package : System.IO.FileAccess -> System.IO.Packaging.Package" Usage="new System.IO.Packaging.Package openFileAccess" />
<MemberSignature Language="C++ CLI" Value="protected:
 Package(System::IO::FileAccess openFileAccess);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.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>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<Parameters>
<Parameter Name="openFileAccess" Type="System.IO.FileAccess" />
</Parameters>
<Docs>
<param name="openFileAccess">The file IO permissions for the package.</param>
<summary>Initializes a new instance of the <see cref="T:System.IO.Packaging.Package" /> class that uses a given <see cref="T:System.IO.FileAccess" />.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.IO.Packaging.Package.%23ctor%2A> is a protected constructor of the <xref:System.IO.Packaging.Package> abstract base class. When called in a derived class, the <xref:System.IO.Packaging.Package.%23ctor%2A> constructor initializes a new instance of the derived class.
]]></format>
</remarks>
<exception cref="T:System.ArgumentOutOfRangeException">The value for <paramref name="openFileAccess" /> is not valid.</exception>
<altmember cref="P:System.IO.Packaging.Package.FileOpenAccess" />
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="protected Package (System.IO.FileAccess openFileAccess, bool streaming);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig specialname rtspecialname instance void .ctor(valuetype System.IO.FileAccess openFileAccess, bool streaming) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Packaging.Package.#ctor(System.IO.FileAccess,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Protected Sub New (openFileAccess As FileAccess, streaming As Boolean)" />
<MemberSignature Language="F#" Value="new System.IO.Packaging.Package : System.IO.FileAccess * bool -> System.IO.Packaging.Package" Usage="new System.IO.Packaging.Package (openFileAccess, streaming)" />
<MemberSignature Language="C++ CLI" Value="protected:
 Package(System::IO::FileAccess openFileAccess, bool streaming);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
</AssemblyInfo>
<Parameters>
<Parameter Name="openFileAccess" Type="System.IO.FileAccess" Index="0" FrameworkAlternate="netframework-3.0;netframework-3.5;netframework-4.0;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" />
<Parameter Name="streaming" Type="System.Boolean" Index="1" FrameworkAlternate="netframework-3.0;netframework-3.5;netframework-4.0;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" />
</Parameters>
<Docs>
<param name="openFileAccess">The file IO permissions for the package.</param>
<param name="streaming">
<see langword="true" /> to open the package for streaming; otherwise, <see langword="false" />.</param>
<summary>Initializes a new instance of the <see cref="T:System.IO.Packaging.Package" /> class that uses a given <see cref="T:System.IO.FileAccess" /> and streaming option.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.IO.Packaging.Package.%23ctor%2A> is a protected constructor of the <xref:System.IO.Packaging.Package> abstract base abstract base class. When called in a derived class, the <xref:System.IO.Packaging.Package.%23ctor%2A> constructor initializes a new instance of the derived class.
]]></format>
</remarks>
<exception cref="T:System.ArgumentOutOfRangeException">The value for <paramref name="openFileAccess" /> is not valid.</exception>
<altmember cref="P:System.IO.Packaging.Package.FileOpenAccess" />
</Docs>
</Member>
<Member MemberName="Close">
<MemberSignature Language="C#" Value="public void Close ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Close() cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Packaging.Package.Close" />
<MemberSignature Language="VB.NET" Value="Public Sub Close ()" />
<MemberSignature Language="F#" Value="member this.Close : unit -> unit" Usage="package.Close " />
<MemberSignature Language="C++ CLI" Value="public:
 void Close();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.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>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Saves and closes the package plus all underlying part streams.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
For the <xref:System.IO.Packaging.Package> class <xref:System.IO.Packaging.Package.Close%2A> and <xref:System.IO.Packaging.Package.Dispose%2A> perform the same operation - there is no reason to call <xref:System.IO.Packaging.Package.Dispose%2A> if you call <xref:System.IO.Packaging.Package.Close%2A>, or vice-versa.
<xref:System.IO.Packaging.Package.Close%2A> and <xref:System.IO.Packaging.Package.Dispose%2A> internally call <xref:System.IO.Packaging.Package.Flush%2A>.
> [!NOTE]
> The `using` statement (different from the `using` namespace directive) is the recommended way to <xref:System.IO.Packaging.Package.Close%2A> and <xref:System.IO.Packaging.Package.Dispose%2A> a package.
]]></format>
</remarks>
<altmember cref="T:System.IO.Packaging.PackagePart" />
<altmember cref="T:System.IO.Packaging.PackageRelationship" />
</Docs>
</Member>
<MemberGroup MemberName="CreatePart">
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Creates a new package part.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.IO.Packaging.Package.CreatePart%2A> initializes an empty <xref:System.IO.Stream> for the new part. The <xref:System.IO.Packaging.PackagePart.GetStream%2A?displayProperty=nameWithType> method can be used to obtain a reference to the stream instance associated with the part.
For more information about package parts, see section 1.1 of the Open Packaging Conventions (OPC) specification available for download at <https://www.ecma-international.org/publications-and-standards/standards/ecma-376/>.
## Examples
The following example shows how to create a new <xref:System.IO.Packaging.PackagePart> and then store data into the part.
:::code language="csharp" source="~/snippets/csharp/System.IO.Packaging/Package/Overview/PackageWrite.cs" id="Snippetpackagewritecreatepart":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/PackageWrite/visualbasic/packagewrite.vb" id="Snippetpackagewritecreatepart":::
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>
<see cref="Overload:System.IO.Packaging.Package.CreatePart" /> internally calls the derived class <see cref="M:System.IO.Packaging.Package.CreatePartCore(System.Uri,System.String,System.IO.Packaging.CompressionOption)" /> method to actually create the part based on the physical format implemented in the derived class.</para>
</block>
</Docs>
</MemberGroup>
<Member MemberName="CreatePart">
<MemberSignature Language="C#" Value="public System.IO.Packaging.PackagePart CreatePart (Uri partUri, string contentType);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.Packaging.PackagePart CreatePart(class System.Uri partUri, string contentType) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Packaging.Package.CreatePart(System.Uri,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function CreatePart (partUri As Uri, contentType As String) As PackagePart" />
<MemberSignature Language="F#" Value="member this.CreatePart : Uri * string -> System.IO.Packaging.PackagePart" Usage="package.CreatePart (partUri, contentType)" />
<MemberSignature Language="C++ CLI" Value="public:
 System::IO::Packaging::PackagePart ^ CreatePart(Uri ^ partUri, System::String ^ contentType);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.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>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.IO.Packaging.PackagePart</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="partUri" Type="System.Uri" />
<Parameter Name="contentType" Type="System.String" />
</Parameters>
<Docs>
<param name="partUri">The uniform resource identifier (URI) of the new part.</param>
<param name="contentType">The content type of the data stream.</param>
<summary>Creates a new uncompressed part with a given URI and content type.</summary>
<returns>The new created part.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.IO.Packaging.Package.CreatePart%2A> initializes an empty <xref:System.IO.Stream> for the new part. The <xref:System.IO.Packaging.PackagePart.GetStream%2A?displayProperty=nameWithType> method can be used to obtain a reference to the stream instance associated with the part.
The part <xref:System.IO.Packaging.PackagePart.CompressionOption%2A> is <xref:System.IO.Packaging.CompressionOption.NotCompressed?displayProperty=nameWithType>.
For additional information about package parts, see section 1.1 in the Open Packaging Conventions (OPC) specification available for download at <https://www.ecma-international.org/publications-and-standards/standards/ecma-376/>.
## Examples
The following example shows how to create a new <xref:System.IO.Packaging.PackagePart> and then store data into the part.
:::code language="csharp" source="~/snippets/csharp/System.IO.Packaging/Package/Overview/PackageWrite.cs" id="Snippetpackagewritecreatepart":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/PackageWrite/visualbasic/packagewrite.vb" id="Snippetpackagewritecreatepart":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="partUri" /> or <paramref name="contentType" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="partUri" /> is not a valid <see cref="T:System.IO.Packaging.PackagePart" /> URI.</exception>
<exception cref="T:System.InvalidOperationException">A part with the specified <paramref name="partUri" /> is already present in the package.</exception>
<exception cref="T:System.ObjectDisposedException">The package is not open (<see cref="M:System.IO.Packaging.Package.Dispose(System.Boolean)" /> or <see cref="M:System.IO.Packaging.Package.Close" /> has been called).</exception>
<exception cref="T:System.IO.IOException">The package is read-only (a new part cannot be added).</exception>
<block subset="none" type="overrides">
<para>
<see cref="M:System.IO.Packaging.Package.CreatePart(System.Uri,System.String)" /> internally calls the derived class's <see cref="M:System.IO.Packaging.Package.CreatePartCore(System.Uri,System.String,System.IO.Packaging.CompressionOption)" /> method to actually create the part based on the physical format implemented in the derived class.</para>
</block>
<altmember cref="M:System.IO.Packaging.Package.DeletePart(System.Uri)" />
<altmember cref="M:System.IO.Packaging.PackUriHelper.CreatePartUri(System.Uri)" />
<altmember cref="M:System.IO.Packaging.PackUriHelper.GetPartUri(System.Uri)" />
<altmember cref="M:System.IO.Packaging.PackUriHelper.ResolvePartUri(System.Uri,System.Uri)" />
<altmember cref="T:System.IO.Packaging.ZipPackagePart" />
</Docs>
</Member>
<Member MemberName="CreatePart">
<MemberSignature Language="C#" Value="public System.IO.Packaging.PackagePart CreatePart (Uri partUri, string contentType, System.IO.Packaging.CompressionOption compressionOption);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.Packaging.PackagePart CreatePart(class System.Uri partUri, string contentType, valuetype System.IO.Packaging.CompressionOption compressionOption) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Packaging.Package.CreatePart(System.Uri,System.String,System.IO.Packaging.CompressionOption)" />
<MemberSignature Language="VB.NET" Value="Public Function CreatePart (partUri As Uri, contentType As String, compressionOption As CompressionOption) As PackagePart" />
<MemberSignature Language="F#" Value="member this.CreatePart : Uri * string * System.IO.Packaging.CompressionOption -> System.IO.Packaging.PackagePart" Usage="package.CreatePart (partUri, contentType, compressionOption)" />
<MemberSignature Language="C++ CLI" Value="public:
 System::IO::Packaging::PackagePart ^ CreatePart(Uri ^ partUri, System::String ^ contentType, System::IO::Packaging::CompressionOption compressionOption);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.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>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.IO.Packaging.PackagePart</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="partUri" Type="System.Uri" />
<Parameter Name="contentType" Type="System.String" />
<Parameter Name="compressionOption" Type="System.IO.Packaging.CompressionOption" />
</Parameters>
<Docs>
<param name="partUri">The URI of the new part.</param>
<param name="contentType">The content type of the data stream.</param>
<param name="compressionOption">The compression option for the data stream, <see cref="F:System.IO.Packaging.CompressionOption.NotCompressed" /> or <see cref="F:System.IO.Packaging.CompressionOption.Normal" /> compression.</param>
<summary>Creates a new part with a given URI, content type, and compression option.</summary>
<returns>The new created part.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
For the default <xref:System.IO.Packaging.ZipPackage> derived class, the <xref:System.IO.Packaging.Package.CreatePart%2A> method only supports two `compressionOption` values, <xref:System.IO.Packaging.CompressionOption.NotCompressed> or <xref:System.IO.Packaging.CompressionOption.Normal> compression. Other <xref:System.IO.Packaging.CompressionOption> values of <xref:System.IO.Packaging.CompressionOption.Maximum>, <xref:System.IO.Packaging.CompressionOption.Fast>, or <xref:System.IO.Packaging.CompressionOption.SuperFast> use <xref:System.IO.Packaging.CompressionOption.Normal> compression.
<xref:System.IO.Packaging.Package.CreatePart%2A> creates an empty <xref:System.IO.Stream> for the new part. The <xref:System.IO.Packaging.PackagePart.GetStream%2A?displayProperty=nameWithType> method can be used to obtain a reference to the stream instance associated with the part.
For additional information, see the Open Packaging Conventions (OPC) specification available for download at <https://www.ecma-international.org/publications-and-standards/standards/ecma-376/>.
## Examples
The following example shows how to create a new <xref:System.IO.Packaging.PackagePart> and then store data into the part.
:::code language="csharp" source="~/snippets/csharp/System.IO.Packaging/Package/Overview/PackageWrite.cs" id="Snippetpackagewritecreatepart":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/PackageWrite/visualbasic/packagewrite.vb" id="Snippetpackagewritecreatepart":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="partUri" /> or <paramref name="contentType" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="partUri" /> is not a valid <see cref="T:System.IO.Packaging.PackagePart" /> uniform resource identifier (URI).</exception>
<exception cref="T:System.InvalidOperationException">A part with the specified <paramref name="partUri" /> is already present in the package.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="compressionOption" /> value is not valid.</exception>
<exception cref="T:System.ObjectDisposedException">The package is not open (<see cref="M:System.IO.Packaging.Package.Dispose(System.Boolean)" /> or <see cref="M:System.IO.Packaging.Package.Close" /> has been called).</exception>
<exception cref="T:System.IO.IOException">The package is read-only (a new part cannot be added).</exception>
<block subset="none" type="overrides">
<para>
<see cref="M:System.IO.Packaging.Package.CreatePart(System.Uri,System.String,System.IO.Packaging.CompressionOption)" /> internally calls the derived class's <see cref="M:System.IO.Packaging.Package.CreatePartCore(System.Uri,System.String,System.IO.Packaging.CompressionOption)" /> method to actually create the part based on the physical format implemented in the derived class.</para>
</block>
<altmember cref="M:System.IO.Packaging.Package.DeletePart(System.Uri)" />
<altmember cref="M:System.IO.Packaging.PackUriHelper.CreatePartUri(System.Uri)" />
<altmember cref="M:System.IO.Packaging.PackUriHelper.GetPartUri(System.Uri)" />
<altmember cref="M:System.IO.Packaging.PackUriHelper.ResolvePartUri(System.Uri,System.Uri)" />
<altmember cref="T:System.IO.Packaging.ZipPackagePart" />
</Docs>
</Member>
<Member MemberName="CreatePartCore">
<MemberSignature Language="C#" Value="protected abstract System.IO.Packaging.PackagePart CreatePartCore (Uri partUri, string contentType, System.IO.Packaging.CompressionOption compressionOption);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance class System.IO.Packaging.PackagePart CreatePartCore(class System.Uri partUri, string contentType, valuetype System.IO.Packaging.CompressionOption compressionOption) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Packaging.Package.CreatePartCore(System.Uri,System.String,System.IO.Packaging.CompressionOption)" />
<MemberSignature Language="VB.NET" Value="Protected MustOverride Function CreatePartCore (partUri As Uri, contentType As String, compressionOption As CompressionOption) As PackagePart" />
<MemberSignature Language="F#" Value="abstract member CreatePartCore : Uri * string * System.IO.Packaging.CompressionOption -> System.IO.Packaging.PackagePart" Usage="package.CreatePartCore (partUri, contentType, compressionOption)" />
<MemberSignature Language="C++ CLI" Value="protected:
 abstract System::IO::Packaging::PackagePart ^ CreatePartCore(Uri ^ partUri, System::String ^ contentType, System::IO::Packaging::CompressionOption compressionOption);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.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>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.IO.Packaging.PackagePart</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="partUri" Type="System.Uri" />
<Parameter Name="contentType" Type="System.String" />
<Parameter Name="compressionOption" Type="System.IO.Packaging.CompressionOption" />
</Parameters>
<Docs>
<param name="partUri">The uniform resource identifier (URI) for the part being created.</param>
<param name="contentType">The content type of the data stream.</param>
<param name="compressionOption">The compression option for the data stream.</param>
<summary>When overridden in a derived class, creates a new part in the package.</summary>
<returns>The created part.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The derived <xref:System.IO.Packaging.Package.CreatePartCore%2A> method is called by the <xref:System.IO.Packaging.Package.CreatePart%2A> method to create a part based on the physical format implemented in the derived class.
By default, a <xref:System.IO.Packaging.ZipPackage> derived class implementation of the abstract <xref:System.IO.Packaging.Package> class is provided and used. In the default operation, <xref:System.IO.Packaging.Package.CreatePart%2A> internally calls <xref:System.IO.Packaging.Package.CreatePartCore%2A> of the <xref:System.IO.Packaging.ZipPackage> class to create a new part in a ZIP file.
For the default <xref:System.IO.Packaging.ZipPackage> derived class, the <xref:System.IO.Packaging.Package.CreatePartCore%2A> method only supports two `compressionOption` values, <xref:System.IO.Packaging.CompressionOption.NotCompressed> or <xref:System.IO.Packaging.CompressionOption.Normal> compression. Other <xref:System.IO.Packaging.CompressionOption> values of <xref:System.IO.Packaging.CompressionOption.Maximum>, <xref:System.IO.Packaging.CompressionOption.Fast>, or <xref:System.IO.Packaging.CompressionOption.SuperFast> use <xref:System.IO.Packaging.CompressionOption.Normal> compression.
For more information about the package model and package parts, see Chapter 1 of the Open Packaging Conventions (OPC) specification available for download at <https://www.ecma-international.org/publications-and-standards/standards/ecma-376/>.
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>The derived <see cref="M:System.IO.Packaging.Package.CreatePartCore(System.Uri,System.String,System.IO.Packaging.CompressionOption)" /> implementation should make no assumptions about the order or operations performed by the <see cref="Overload:System.IO.Packaging.Package.CreatePart" /> method that calls it.</para>
</block>
<altmember cref="M:System.IO.Packaging.Package.DeletePartCore(System.Uri)" />
</Docs>
</Member>
<MemberGroup MemberName="CreateRelationship">
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Creates a package-level relationship to a given part.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
A package-level relationship defines an association between the package and an associated target part or resource. A package-level relationship can be one of two forms.
- Between a <xref:System.IO.Packaging.Package> to a target <xref:System.IO.Packaging.PackagePart> inside the package.
- Between a <xref:System.IO.Packaging.Package> to a target resource outside the package.
In a package-relationship the package is considered the "owner" of the relationship. When the package is deleted, all the relationships owned by the package are also deleted. The process of creating or deleting the relationship does not physically alter the target part or resource in any way.
For additional information, see the Open Packaging Conventions (OPC) specification available for download at <https://www.ecma-international.org/publications-and-standards/standards/ecma-376/>.
## Examples
The following example illustrates creating a <xref:System.IO.Packaging.PackageRelationship> between a <xref:System.IO.Packaging.Package> and a root document part.
:::code language="csharp" source="~/snippets/csharp/System.IO.Packaging/Package/Overview/PackageWrite.cs" id="Snippetpackagewritecreatepackagerelationship":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/PackageWrite/visualbasic/packagewrite.vb" id="Snippetpackagewritecreatepackagerelationship":::
]]></format>
</remarks>
</Docs>
</MemberGroup>
<Member MemberName="CreateRelationship">
<MemberSignature Language="C#" Value="public System.IO.Packaging.PackageRelationship CreateRelationship (Uri targetUri, System.IO.Packaging.TargetMode targetMode, string relationshipType);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.Packaging.PackageRelationship CreateRelationship(class System.Uri targetUri, valuetype System.IO.Packaging.TargetMode targetMode, string relationshipType) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Packaging.Package.CreateRelationship(System.Uri,System.IO.Packaging.TargetMode,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function CreateRelationship (targetUri As Uri, targetMode As TargetMode, relationshipType As String) As PackageRelationship" />
<MemberSignature Language="F#" Value="member this.CreateRelationship : Uri * System.IO.Packaging.TargetMode * string -> System.IO.Packaging.PackageRelationship" Usage="package.CreateRelationship (targetUri, targetMode, relationshipType)" />
<MemberSignature Language="C++ CLI" Value="public:
 System::IO::Packaging::PackageRelationship ^ CreateRelationship(Uri ^ targetUri, System::IO::Packaging::TargetMode targetMode, System::String ^ relationshipType);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.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>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.IO.Packaging.PackageRelationship</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="targetUri" Type="System.Uri" />
<Parameter Name="targetMode" Type="System.IO.Packaging.TargetMode" />
<Parameter Name="relationshipType" Type="System.String" />
</Parameters>
<Docs>
<param name="targetUri">The uniform resource identifier (URI) of the target part.</param>
<param name="targetMode">Indicates if the target part is <see cref="F:System.IO.Packaging.TargetMode.Internal" /> or <see cref="F:System.IO.Packaging.TargetMode.External" /> to the package.</param>
<param name="relationshipType">A URI that uniquely defines the role of the relationship.</param>
<summary>Creates a package-level relationship to a part with a given URI, target mode, and relationship type.</summary>
<returns>The package-level relationship to the specified part.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
A package-level relationship defines an association between the package and an associated target part or resource. A package-level relationship can be one of two forms.
- Between a <xref:System.IO.Packaging.Package> to a target part in the package.
- Between a <xref:System.IO.Packaging.Package> to a target resource outside the package.
In a package-relationship the package is considered the "owner" of the relationship. When the package is deleted, all the relationships owned by the package are also deleted.
<xref:System.IO.Packaging.Package.CreateRelationship%2A> does not physically change the target part or resource in any way.
The target of a relationship cannot be another relationship.
If `targetMode` is specified as <xref:System.IO.Packaging.TargetMode.Internal>, `targetUri` must be a relative URI that is formed according to the [RFC 3986](https://tools.ietf.org/html/rfc3986) Uniform Resource Identifier (URI) Generic Syntax specification. The internal relative URI can be either an absolute path that starts with a forward slash ("/") character such as "/page1.xaml" or "/images/picture4.jpg", or a relative path such as "../imagespicture1.jpg" that resolves against the package root ("/") as the base URI.
If `targetMode` is specified as <xref:System.IO.Packaging.TargetMode.External>, `targetUri` can be either an absolute or relative URI formed according to the [RFC 3986](https://tools.ietf.org/html/rfc3986) Uniform Resource Identifier (URI) Generic Syntax specification. `http://www.microsoft.com/page2.xml` is an example of an absolute URI that references an external target resource "page2.xml". "images/picture1.jpg" is an example of a relative URI that also references an external target resource "1.jpg" but which resolves against the URI of the package itself.
`relationshipType` must be a URI that is formed according to the [RFC 3986](https://tools.ietf.org/html/rfc3986) Uniform Resource Identifier (URI) Generic Syntax specification. The following table shows the package-level `relationshipType` URIs defined by the Open Packaging Conventions (OPC) specification.
|Package-level Relationship|Relationship Type URI|
|---------------------------------|---------------------------|
|Core Properties|`http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties`|
|Digital Signature|`http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature`|
|Digital Signature Certificate|`http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/certificate`|
|Digital Signature Origin|`http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin`|
|Thumbnail|`http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail`|
For more information about packaging and package relationships, see section 1.3 of the Open Packaging Conventions (OPC) specification available for download at <https://www.ecma-international.org/publications-and-standards/standards/ecma-376/>.
## Examples
The following example illustrates how to use <xref:System.IO.Packaging.Package.CreateRelationship%2A> to create a <xref:System.IO.Packaging.PackageRelationship> between a <xref:System.IO.Packaging.Package> and a root document part.
:::code language="csharp" source="~/snippets/csharp/System.IO.Packaging/Package/Overview/PackageWrite.cs" id="Snippetpackagewritecreatepackagerelationship":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/PackageWrite/visualbasic/packagewrite.vb" id="Snippetpackagewritecreatepackagerelationship":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="targetUri" /> or <paramref name="relationshipType" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">The <paramref name="targetUri" /> part is a <see cref="T:System.IO.Packaging.PackageRelationship" />, or <paramref name="targetMode" /> is <see cref="F:System.IO.Packaging.TargetMode.Internal" /> and <paramref name="targetUri" /> is an absolute URI.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">The value for <paramref name="targetMode" /> is not valid.</exception>
<exception cref="T:System.ObjectDisposedException">The package is not open (<see cref="M:System.IO.Packaging.Package.Dispose(System.Boolean)" /> or <see cref="M:System.IO.Packaging.Package.Close" /> has been called).</exception>
<exception cref="T:System.IO.IOException">The package is read-only.</exception>
<altmember cref="M:System.IO.Packaging.Package.DeleteRelationship(System.String)" />
<altmember cref="M:System.IO.Packaging.Package.GetRelationship(System.String)" />
<altmember cref="M:System.IO.Packaging.Package.GetRelationships" />
<altmember cref="M:System.IO.Packaging.Package.GetRelationshipsByType(System.String)" />
<altmember cref="M:System.IO.Packaging.Package.RelationshipExists(System.String)" />
</Docs>
</Member>
<Member MemberName="CreateRelationship">
<MemberSignature Language="C#" Value="public System.IO.Packaging.PackageRelationship CreateRelationship (Uri targetUri, System.IO.Packaging.TargetMode targetMode, string relationshipType, string? id);" FrameworkAlternate="net-6.0;net-7.0;net-8.0;net-9.0;netstandard-2.0;windowsdesktop-5.0;windowsdesktop-6.0;windowsdesktop-7.0;windowsdesktop-8.0;windowsdesktop-9.0" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.IO.Packaging.PackageRelationship CreateRelationship(class System.Uri targetUri, valuetype System.IO.Packaging.TargetMode targetMode, string relationshipType, string id) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Packaging.Package.CreateRelationship(System.Uri,System.IO.Packaging.TargetMode,System.String,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function CreateRelationship (targetUri As Uri, targetMode As TargetMode, relationshipType As String, id As String) As PackageRelationship" />
<MemberSignature Language="F#" Value="member this.CreateRelationship : Uri * System.IO.Packaging.TargetMode * string * string -> System.IO.Packaging.PackageRelationship" Usage="package.CreateRelationship (targetUri, targetMode, relationshipType, id)" />
<MemberSignature Language="C++ CLI" Value="public:
 System::IO::Packaging::PackageRelationship ^ CreateRelationship(Uri ^ targetUri, System::IO::Packaging::TargetMode targetMode, System::String ^ relationshipType, System::String ^ id);" />
<MemberSignature Language="C#" Value="public System.IO.Packaging.PackageRelationship CreateRelationship (Uri targetUri, System.IO.Packaging.TargetMode targetMode, string relationshipType, string id);" FrameworkAlternate="netcore-1.0;netcore-1.1;netframework-3.0;netframework-3.5;netframework-4.0;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;windowsdesktop-3.0;windowsdesktop-3.1" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.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>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.IO.Packaging.PackageRelationship</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="targetUri" Type="System.Uri" />
<Parameter Name="targetMode" Type="System.IO.Packaging.TargetMode" />
<Parameter Name="relationshipType" Type="System.String" />
<Parameter Name="id" Type="System.String">
<Attributes>
<Attribute FrameworkAlternate="net-8.0;net-9.0;windowsdesktop-8.0;windowsdesktop-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="targetUri">The uniform resource identifier (URI) of the target part.</param>
<param name="targetMode">Indicates if the target part is <see cref="F:System.IO.Packaging.TargetMode.Internal" /> or <see cref="F:System.IO.Packaging.TargetMode.External" /> to the package.</param>
<param name="relationshipType">A URI that uniquely defines the role of the relationship.</param>
<param name="id">A unique XML identifier.</param>
<summary>Creates a package-level relationship to a part with a given URI, target mode, relationship type, and identifier (ID).</summary>
<returns>The package-level relationship to the specified part.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
A package-level relationship defines an association between the package and an associated target part or resource. A package-level relationship can be one of two forms.
- Between a <xref:System.IO.Packaging.Package> to a target part in the package.
- Between a <xref:System.IO.Packaging.Package> to a target resource outside the package.
In a package-relationship the package is considered the "owner" of the relationship. When the package is deleted, all the relationships owned by the package are also deleted.
<xref:System.IO.Packaging.Package.CreateRelationship%2A> does not physically change the target part or resource in any way.
The target of a relationship cannot be another relationship.
`id` must be a valid XML identifier. The `id` type is xsd:ID and must follow the naming conventions prescribed in the XML Schema Part 2: Datatypes specification (see [https://www.w3.org/TR/xmlschema-2/#ID](https://www.w3.org/TR/xmlschema-2/#ID)).
If `id` is specified as `null` a unique ID will be automatically generated. An `id` specified by an empty string is not valid.
If `targetMode` is specified as <xref:System.IO.Packaging.TargetMode.Internal>, `targetUri` must be a relative URI that is formed according to the [RFC 3986](https://tools.ietf.org/html/rfc3986) Uniform Resource Identifier (URI) Generic Syntax specification. The internal relative URI can be either an absolute path that starts with a forward slash ("/") character such as "/page1.xaml" or "/images/picture4.jpg", or a relative path such as "../imagespicture1.jpg" that resolves against the package root ("/") as the base URI.
If `targetMode` is specified as <xref:System.IO.Packaging.TargetMode.External>, `targetUri` can be either an absolute or relative URI formed according to the [RFC 3986](https://tools.ietf.org/html/rfc3986) Uniform Resource Identifier (URI) Generic Syntax specification. `http://www.microsoft.com/page2.xml` is an example of an absolute URI that references an external target resource "page2.xml". "images/picture1.jpg" is an example of a relative URI that also references an external target resource "1.jpg" but which resolves against the URI of the package itself.
`relationshipType` must be a URI that is formed according to the [RFC 3986](https://tools.ietf.org/html/rfc3986) Uniform Resource Identifier (URI) Generic Syntax specification. The following table shows the package-level `relationshipType` URIs defined by the Open Packaging Conventions (OPC) specification.
|Package-level Relationship|Relationship Type URI|
|---------------------------------|---------------------------|
|Core Properties|`http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties`|
|Digital Signature|`http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature`|
|Digital Signature Certificate|`http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/certificate`|
|Digital Signature Origin|`http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin`|
|Thumbnail|`http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail`|
For additional information about packaging and package relationships, see section 1.3 of the Open Packaging Conventions (OPC) specification available for download at <https://www.ecma-international.org/publications-and-standards/standards/ecma-376/>.
## Examples
The following example illustrates how to use <xref:System.IO.Packaging.Package.CreateRelationship%2A> to create a <xref:System.IO.Packaging.PackageRelationship> between a <xref:System.IO.Packaging.Package> and a root document part.
:::code language="csharp" source="~/snippets/csharp/System.IO.Packaging/Package/Overview/PackageWrite.cs" id="Snippetpackagewritecreatepackagerelationship":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/PackageWrite/visualbasic/packagewrite.vb" id="Snippetpackagewritecreatepackagerelationship":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="targetUri" /> or <paramref name="relationshipType" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">The <paramref name="targetUri" /> part is a <see cref="T:System.IO.Packaging.PackageRelationship" />, or <paramref name="targetMode" /> is <see cref="F:System.IO.Packaging.TargetMode.Internal" /> and <paramref name="targetUri" /> is an absolute URI.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">The value for <paramref name="targetMode" /> is not valid.</exception>
<exception cref="T:System.ObjectDisposedException">The package is not open (<see cref="M:System.IO.Packaging.Package.Dispose(System.Boolean)" /> or <see cref="M:System.IO.Packaging.Package.Close" /> has been called).</exception>
<exception cref="T:System.IO.IOException">The package is read-only.</exception>
<exception cref="T:System.Xml.XmlException">
<paramref name="id" /> is not a valid XML identifier; or a part with the specified <paramref name="id" /> already occurs in the package.</exception>
<altmember cref="M:System.IO.Packaging.Package.CreateRelationship(System.Uri,System.IO.Packaging.TargetMode,System.String)" />
<altmember cref="M:System.IO.Packaging.Package.DeleteRelationship(System.String)" />
<altmember cref="M:System.IO.Packaging.Package.GetRelationship(System.String)" />
<altmember cref="M:System.IO.Packaging.Package.GetRelationships" />
<altmember cref="M:System.IO.Packaging.Package.GetRelationshipsByType(System.String)" />
<altmember cref="M:System.IO.Packaging.Package.RelationshipExists(System.String)" />
</Docs>
</Member>
<Member MemberName="DeletePart">
<MemberSignature Language="C#" Value="public void DeletePart (Uri partUri);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void DeletePart(class System.Uri partUri) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Packaging.Package.DeletePart(System.Uri)" />
<MemberSignature Language="VB.NET" Value="Public Sub DeletePart (partUri As Uri)" />
<MemberSignature Language="F#" Value="member this.DeletePart : Uri -> unit" Usage="package.DeletePart partUri" />
<MemberSignature Language="C++ CLI" Value="public:
 void DeletePart(Uri ^ partUri);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.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>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="partUri" Type="System.Uri" />
</Parameters>
<Docs>
<param name="partUri">The URI of the part to delete.</param>
<summary>Deletes a part with a given URI from the package.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
`partUri` must be a relative URI that consists of an absolute path which starts with a forward slash ("/") character. The absolute path is relative to the package root and is formed according to the [RFC 3986](https://tools.ietf.org/html/rfc3986) Uniform Resource Identifier (URI) Generic Syntax specification. "/page1.xaml" and "/images/picture4.jpg" are examples of valid part URIs.
No exception is raised if a part with the specified `partUri` is not in the package. (You can use the <xref:System.IO.Packaging.Package.PartExists%2A> method to determine whether a part with a specified `partUri` is in the package.)
For additional information, see the Open Packaging Conventions (OPC) specification available for download at <https://www.ecma-international.org/publications-and-standards/standards/ecma-376/>.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="partUri" /> is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">
<paramref name="partUri" /> is not a valid <see cref="T:System.IO.Packaging.PackagePart" /> URI.</exception>
<exception cref="T:System.ObjectDisposedException">The package is not open (<see cref="M:System.IO.Packaging.Package.Dispose(System.Boolean)" /> or <see cref="M:System.IO.Packaging.Package.Close" /> has been called).</exception>
<exception cref="T:System.IO.IOException">The package is read-only.</exception>
<block subset="none" type="overrides">
<para>
<see cref="M:System.IO.Packaging.Package.DeletePart(System.Uri)" /> internally calls the derived class's <see cref="M:System.IO.Packaging.Package.DeletePartCore(System.Uri)" /> method to actually delete the part based on the physical format implemented in the derived class.</para>
</block>
<altmember cref="Overload:System.IO.Packaging.Package.CreatePart" />
<altmember cref="M:System.IO.Packaging.PackUriHelper.CreatePartUri(System.Uri)" />
<altmember cref="M:System.IO.Packaging.PackUriHelper.GetPartUri(System.Uri)" />
<altmember cref="M:System.IO.Packaging.PackUriHelper.ResolvePartUri(System.Uri,System.Uri)" />
</Docs>
</Member>
<Member MemberName="DeletePartCore">
<MemberSignature Language="C#" Value="protected abstract void DeletePartCore (Uri partUri);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void DeletePartCore(class System.Uri partUri) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Packaging.Package.DeletePartCore(System.Uri)" />
<MemberSignature Language="VB.NET" Value="Protected MustOverride Sub DeletePartCore (partUri As Uri)" />
<MemberSignature Language="F#" Value="abstract member DeletePartCore : Uri -> unit" Usage="package.DeletePartCore partUri" />
<MemberSignature Language="C++ CLI" Value="protected:
 abstract void DeletePartCore(Uri ^ partUri);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.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>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="partUri" Type="System.Uri" />
</Parameters>
<Docs>
<param name="partUri">The <see cref="P:System.IO.Packaging.PackagePart.Uri" /> of the <see cref="T:System.IO.Packaging.PackagePart" /> to delete.</param>
<summary>When overridden in a derived class, deletes a part with a given URI.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
By default, a <xref:System.IO.Packaging.ZipPackage> derived class implementation of the abstract <xref:System.IO.Packaging.Package> class is provided and used. In the default operation, <xref:System.IO.Packaging.Package.DeletePart%2A> internally calls <xref:System.IO.Packaging.Package.DeletePartCore%2A> of the <xref:System.IO.Packaging.ZipPackage> class to perform the actual delete operation based on the physical format implemented in the derived class.
For more information about the package model and package parts, see Chapter 1 of the Open Packaging Conventions (OPC) specification available for download at <https://www.ecma-international.org/publications-and-standards/standards/ecma-376/>.
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>The derived class <see cref="M:System.IO.Packaging.Package.DeletePartCore(System.Uri)" /> implementation is called by the <see cref="M:System.IO.Packaging.Package.DeletePart(System.Uri)" /> method to the specified part based on the physical format implemented in the derived class.
The derived <see cref="M:System.IO.Packaging.Package.DeletePartCore(System.Uri)" /> implementation should make no assumptions about the order or operations performed by the <see cref="M:System.IO.Packaging.Package.DeletePart(System.Uri)" /> method that calls it.</para>
</block>
<altmember cref="M:System.IO.Packaging.Package.CreatePartCore(System.Uri,System.String,System.IO.Packaging.CompressionOption)" />
</Docs>
</Member>
<Member MemberName="DeleteRelationship">
<MemberSignature Language="C#" Value="public void DeleteRelationship (string id);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void DeleteRelationship(string id) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Packaging.Package.DeleteRelationship(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub DeleteRelationship (id As String)" />
<MemberSignature Language="F#" Value="member this.DeleteRelationship : string -> unit" Usage="package.DeleteRelationship id" />
<MemberSignature Language="C++ CLI" Value="public:
 void DeleteRelationship(System::String ^ id);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.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>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="id" Type="System.String" />
</Parameters>
<Docs>
<param name="id">The <see cref="P:System.IO.Packaging.PackageRelationship.Id" /> of the <see cref="T:System.IO.Packaging.PackageRelationship" /> to delete.</param>
<summary>Deletes a package-level relationship.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
A package-level relationship defines an association between the package and an associated target part or resource. A package-level relationship can be one of two forms.
- Between a <xref:System.IO.Packaging.Package> to a target part in the package.
- Between a <xref:System.IO.Packaging.Package> to a target resource outside the package.
In a package-relationship the package is considered the "owner" of the relationship. When the package is deleted, all the relationships owned by the package are also deleted.
No exception is raised if a relationship with the specified `id` is not in the package.
<xref:System.IO.Packaging.Package.DeleteRelationship%2A> does not physically change the target part in any way.
For more information about package relationships, see section 1.3 of the Open Packaging Conventions (OPC) specification available for download at <https://www.ecma-international.org/publications-and-standards/standards/ecma-376/>.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="id" /> is <see langword="null" />.</exception>
<exception cref="T:System.ObjectDisposedException">The package is not open (<see cref="M:System.IO.Packaging.Package.Dispose(System.Boolean)" /> or <see cref="M:System.IO.Packaging.Package.Close" /> has been called).</exception>
<exception cref="T:System.IO.IOException">The package is read-only.</exception>
<exception cref="T:System.Xml.XmlException">
<paramref name="id" /> is not a valid XML identifier.</exception>
</Docs>
</Member>
<Member MemberName="Dispose">
<MemberSignature Language="C#" Value="protected virtual void Dispose (bool disposing);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void Dispose(bool disposing) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Packaging.Package.Dispose(System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Sub Dispose (disposing As Boolean)" />
<MemberSignature Language="F#" Value="abstract member Dispose : bool -> unit
override this.Dispose : bool -> unit" Usage="package.Dispose disposing" />
<MemberSignature Language="C++ CLI" Value="protected:
 virtual void Dispose(bool disposing);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.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>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="disposing" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="disposing">
<see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.</param>
<summary>Flushes and saves the content of all parts and relationships, closes the package, and releases all resources.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
To make sure that all changes are correctly saved, <xref:System.IO.Packaging.Package.Dispose%2A> also finalizes, flushes, and closes all parts and relationships that are contained in the package.
For the <xref:System.IO.Packaging.Package> class, <xref:System.IO.Packaging.Package.Dispose%2A> and <xref:System.IO.Packaging.Package.Close%2A> perform the same operation - there is no reason to call <xref:System.IO.Packaging.Package.Dispose%2A> if you call <xref:System.IO.Packaging.Package.Close%2A>, or vice-versa.
<xref:System.IO.Packaging.Package.Close%2A> and <xref:System.IO.Packaging.Package.Dispose%2A> internally call <xref:System.IO.Packaging.Package.Flush%2A>.
Derived classes that allocate and manage non-memory resources should override this method to release resources when <xref:System.IO.Packaging.Package.Dispose%2A> is called. Derived-class overrides should also call <xref:System.IO.Packaging.Package.Flush%2A> and the base-class <xref:System.IO.Packaging.Package.Dispose%2A> method to make sure that base-class cleanup is always performed.
> [!NOTE]
> The `using` statement (different from the `using` namespace directive) is the recommended way to <xref:System.IO.Packaging.Package.Close%2A> and <xref:System.IO.Packaging.Package.Dispose%2A> a package.
]]></format>
</remarks>
<altmember cref="M:System.IO.Packaging.Package.Flush" />
<altmember cref="T:System.IO.Packaging.PackagePart" />
<altmember cref="T:System.IO.Packaging.PackageRelationship" />
</Docs>
</Member>
<Member MemberName="FileOpenAccess">
<MemberSignature Language="C#" Value="public System.IO.FileAccess FileOpenAccess { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.IO.FileAccess FileOpenAccess" />
<MemberSignature Language="DocId" Value="P:System.IO.Packaging.Package.FileOpenAccess" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property FileOpenAccess As FileAccess" />
<MemberSignature Language="F#" Value="member this.FileOpenAccess : System.IO.FileAccess" Usage="System.IO.Packaging.Package.FileOpenAccess" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::IO::FileAccess FileOpenAccess { System::IO::FileAccess get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.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>WindowsBase</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.IO.FileAccess</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the file access setting for the package.</summary>
<value>One of the <see cref="T:System.IO.FileAccess" /> values: <see cref="F:System.IO.FileAccess.Read" />, <see cref="F:System.IO.FileAccess.Write" />, or <see cref="F:System.IO.FileAccess.ReadWrite" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.IO.Packaging.Package.FileOpenAccess%2A> property has no default value. The file access setting is specified in the <xref:System.IO.Packaging.Package.%23ctor%2A> constructor call when you create a new package, or in the <xref:System.IO.Packaging.Package.Open%2A> call when you open an existing package.
]]></format>
</remarks>
<exception cref="T:System.ObjectDisposedException">The package is not open (<see cref="M:System.IO.Packaging.Package.Dispose(System.Boolean)" /> or <see cref="M:System.IO.Packaging.Package.Close" /> has been called).</exception>
</Docs>
</Member>
<Member MemberName="Flush">
<MemberSignature Language="C#" Value="public void Flush ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Flush() cil managed" />
<MemberSignature Language="DocId" Value="M:System.IO.Packaging.Package.Flush" />
<MemberSignature Language="VB.NET" Value="Public Sub Flush ()" />
<MemberSignature Language="F#" Value="member this.Flush : unit -> unit" Usage="package.Flush " />
<MemberSignature Language="C++ CLI" Value="public:
 void Flush();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IO.Packaging</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.4.0</AssemblyVersion>