Skip to content

Commit

Permalink
Remove incorrect exception (#6809)
Browse files Browse the repository at this point in the history
  • Loading branch information
gewarren authored Jul 13, 2021
1 parent 87abb6d commit 9fedbfa
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 80 deletions.
19 changes: 3 additions & 16 deletions includes/remarks/System.IO.Compression/ZipFile/ZipFile.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
> [!IMPORTANT]
> To use the <xref:System.IO.Compression.ZipFile> class, you must add a reference to the `System.IO.Compression.FileSystem` assembly in your project; otherwise, you'll get the following error message when trying to compile : **The name 'ZipFile' does not exist in the current context**. For more information on how to add a reference to your project in Visual Studio, see [How to: Add or Remove References By Using the Reference Manager](/visualstudio/ide/how-to-add-or-remove-references-by-using-the-reference-manager).
> [!NOTE]
> To use the <xref:System.IO.Compression.ZipFile> class in a .NET Framework app, you must add a reference to the `System.IO.Compression.FileSystem` assembly in your project. For information on how to add a reference to your project in Visual Studio, see [How to: Add or Remove References](/visualstudio/ide/how-to-add-or-remove-references-by-using-the-reference-manager).
The methods for manipulating zip archives and their files are spread across three classes: <xref:System.IO.Compression.ZipFile>, <xref:System.IO.Compression.ZipArchive> and <xref:System.IO.Compression.ZipArchiveEntry>.
The methods for manipulating zip archives and their files are spread across three classes: <xref:System.IO.Compression.ZipFile>, <xref:System.IO.Compression.ZipArchive>, and <xref:System.IO.Compression.ZipArchiveEntry>.

|To...|Use...|
|---------|----------|
Expand All @@ -13,22 +13,9 @@ The methods for manipulating zip archives and their files are spread across thre
|To open a stream to an individual file contained in a zip archive|<xref:System.IO.Compression.ZipArchiveEntry.Open%2A?displayProperty=nameWithType>|
|Delete a file from a zip archive|<xref:System.IO.Compression.ZipArchiveEntry.Delete%2A?displayProperty=nameWithType>|

You cannot use the <xref:System.IO.Compression.ZipFile> or <xref:System.IO.Compression.ZipFileExtensions> classes in Windows 8.x Store apps. In Windows 8.x Store apps, you should use the following classes to work with compressed files.

- <xref:System.IO.Compression.ZipArchive>

- <xref:System.IO.Compression.ZipArchiveEntry>

- <xref:System.IO.Compression.DeflateStream>

- <xref:System.IO.Compression.GZipStream>

## 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.

> [!TIP]
> 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="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.io.compression.zipfile/cs/program1.cs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.zipfile/vb/program1.vb" id="Snippet1":::
70 changes: 29 additions & 41 deletions xml/System.IO.Compression/ZipFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
]]></format>
</remarks>
<related type="Article" href="/visualstudio/ide/how-to-add-or-remove-references-by-using-the-reference-manager">How to: Add or Remove References By Using the Reference Manager</related>
</Docs>
<Members>
<MemberGroup MemberName="CreateFromDirectory">
Expand Down Expand Up @@ -407,19 +406,15 @@ An I/O error occurred while opening a file to be archived.</exception>
<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 directory specified by <paramref name="destinationDirectoryName" /> already exists.

-or-

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.
<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 from the same archive.</exception>
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>
Expand Down Expand Up @@ -477,15 +472,14 @@ An I/O error occurred while opening a file to be archived.</exception>
<format type="text/markdown"><![CDATA[
## Remarks
If `overwriteFiles` is `false`, the specified directory must not exist; otherwise, this method will only create the specified directory and all subdirectories if necessary. The parent directory must exists regardless.
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.
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>
Expand All @@ -497,7 +491,7 @@ An I/O error occurred while opening a file to be archived.</exception>
<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 the directory specified by <paramref name="destinationDirectoryName" /> already exists.
<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-

Expand All @@ -513,7 +507,7 @@ Extracting a <see cref="T:System.IO.Compression.ZipArchiveEntry" /> would result

-or-

A <see cref="T:System.IO.Compression.ZipArchiveEntry" /> has the same name as an already extracted entry from the same archive.</exception>
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>
Expand Down Expand Up @@ -576,21 +570,20 @@ A <see cref="T:System.IO.Compression.ZipArchiveEntry" /> has been compressed usi
<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.
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.
- For entries where the language encoding flag is set, the entry names are decoded by using UTF-8.
If `entryNameEncoding` is set to `null`, entry names are decoded according to the following rules:
- For entries where the language encoding flag (in the general-purpose bit flag of the local file header) is not set, entry names are decoded by using the current system default code page.
- For entries where the language encoding flag is set, the entry names are decoded by using UTF-8.
## 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.
- For entries where the language encoding flag is set, the entry names are decoded by using UTF-8.
If `entryNameEncoding` is set to `null`, entry names are decoded according to the following rules:
- For entries where the language encoding flag (in the general-purpose bit flag of the local file header) is not set, entry names are decoded by using the current system default code page.
- For entries where the language encoding flag is set, the entry names are decoded by using UTF-8.
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
Expand All @@ -603,19 +596,15 @@ A <see cref="T:System.IO.Compression.ZipArchiveEntry" /> has been compressed usi
<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 directory specified by <paramref name="destinationDirectoryName" /> already exists.

-or-

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.
<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 from the same archive.</exception>
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>
Expand Down Expand Up @@ -676,7 +665,6 @@ A <see cref="T:System.IO.Compression.ZipArchiveEntry" /> has been compressed usi
<format type="text/markdown"><![CDATA[
## Remarks
If `overwriteFiles` is `false`, the specified directory must not exist; otherwise, this method will only create the specified directory and all subdirectories if necessary. The parent directory must exists regardless.
If there is an error while extracting the archive, the archive will remain partially extracted.
Expand All @@ -700,7 +688,7 @@ A <see cref="T:System.IO.Compression.ZipArchiveEntry" /> has been compressed usi
<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 the directory specified by <paramref name="destinationDirectoryName" /> already exists.
<paramref name="overwriteFiles"/> is <see langword="false"/> and an archive entry to extract has the same name as a file that already exists in <paramref name="destinationDirectoryName" />.

-or-

Expand Down
Loading

0 comments on commit 9fedbfa

Please sign in to comment.