Skip to content

Merge main into live #11622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ If you reference the `System.IO.Compression.FileSystem` assembly in your project
The first example shows how to create a new entry and write to it by using a stream.

:::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipArchive/CreateEntry/program1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.ziparchivemode/vb/program1.vb" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipArchive/CreateEntry/program1.vb" id="Snippet1":::

The following example shows how to open a zip archive and iterate through the collection of entries.

:::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipArchive/Entries/program1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.ziparchive/vb/program1.vb" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipArchive/Entries/program1.vb" id="Snippet1":::

The third example shows how to use extension methods to create a new entry in a zip archive from an existing file and extract the archive contents. You must reference the `System.IO.Compression.FileSystem` assembly to execute the code.

:::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipArchive/Entries/program3.cs" id="Snippet3":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.ziparchive/vb/program3.vb" id="Snippet3":::
:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipArchive/Entries/program3.vb" id="Snippet3":::
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ You can specify any string as the path of an entry, including strings that speci
The following example shows how to iterate through the contents of a .zip file, and extract files that contain the .txt extension.

:::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipArchive/Entries/program1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.ziparchive/vb/program1.vb" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipArchive/Entries/program1.vb" id="Snippet1":::
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ When you set this property, the <xref:System.DateTimeOffset> value is converted
The following example shows how to open an entry in a zip archive, modify it, and set the <xref:System.IO.Compression.ZipArchiveEntry.LastWriteTime%2A> property to the current time.

:::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipArchive/GetEntry/program2.cs" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.ziparchiveentry/vb/program2.vb" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipArchive/GetEntry/program2.vb" id="Snippet2":::
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ The <xref:System.IO.Compression.ZipArchiveEntry.Name%2A> property contains the p
The following example shows how to retrieve entries from a zip archive and evaluate the properties of the entries. It uses the <xref:System.IO.Compression.ZipArchiveEntry.Name%2A> property to display the name of the entry, and the <xref:System.IO.Compression.ZipArchiveEntry.Length%2A> and <xref:System.IO.Compression.ZipArchiveEntry.CompressedLength%2A> properties to calculate how much the file was compressed.

:::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipArchive/GetEntry/program1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.ziparchiveentry/vb/program1.vb" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipArchive/GetEntry/program1.vb" id="Snippet1":::
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ If you reference the `System.IO.Compression.FileSystem` assembly in your project
The first example shows how to create a new entry in a zip archive and write to it.

:::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipArchive/CreateEntry/program1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.ziparchivemode/vb/program1.vb" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipArchive/CreateEntry/program1.vb" id="Snippet1":::

The second example shows how to use the <xref:System.IO.Compression.ZipFileExtensions.ExtractToFile%28System.IO.Compression.ZipArchiveEntry%2CSystem.String%29> extension method. You must reference the `System.IO.Compression.FileSystem` assembly in your project for the code to execute.

:::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipArchive/Entries/program1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.ziparchive/vb/program1.vb" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipArchive/Entries/program1.vb" id="Snippet1":::
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ The following methods include a parameter named `mode` that lets you specify the
The following example shows how to specify a `ZipArchiveMode` value when creating a <xref:System.IO.Compression.ZipArchive> object.

:::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipArchive/CreateEntry/program1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.ziparchivemode/vb/program1.vb" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipArchive/CreateEntry/program1.vb" id="Snippet1":::
18 changes: 9 additions & 9 deletions includes/remarks/System.IO.Compression/ZipFile/ZipFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

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...|
|---------|----------|
|Create a zip archive from a directory|<xref:System.IO.Compression.ZipFile.CreateFromDirectory%2A?displayProperty=nameWithType>|
|Extract the contents of a zip archive to a directory|<xref:System.IO.Compression.ZipFile.ExtractToDirectory%2A?displayProperty=nameWithType>|
|Add new files to an existing zip archive|<xref:System.IO.Compression.ZipArchive.CreateEntry%2A?displayProperty=nameWithType>|
|Retrieve a file in a zip archive|<xref:System.IO.Compression.ZipArchive.GetEntry%2A?displayProperty=nameWithType>|
|Retrieve all of the files in a zip archive|<xref:System.IO.Compression.ZipArchive.Entries%2A?displayProperty=nameWithType>|
|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>|
| To... | Use... |
|---------------------------------------|--------|
| Create a zip archive from a directory | <xref:System.IO.Compression.ZipFile.CreateFromDirectory%2A?displayProperty=nameWithType> |
| Extract the contents of a zip archive to a directory | <xref:System.IO.Compression.ZipFile.ExtractToDirectory%2A?displayProperty=nameWithType> |
| Add new files to an existing zip archive | <xref:System.IO.Compression.ZipArchive.CreateEntry%2A?displayProperty=nameWithType> |
| Retrieve a file in a zip archive | <xref:System.IO.Compression.ZipArchive.GetEntry%2A?displayProperty=nameWithType> |
| Retrieve all of the files in a zip archive | <xref:System.IO.Compression.ZipArchive.Entries%2A?displayProperty=nameWithType> |
| 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> |

## Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ The <xref:System.IO.Compression.ZipFileExtensions> class contains two methods th
The following example shows how to create a new entry in a zip archive from an existing file, and extract the contents of the archive to a directory.

:::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipArchive/Entries/program3.cs" id="Snippet3":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.ziparchive/vb/program3.vb" id="Snippet3":::
:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipArchive/Entries/program3.vb" id="Snippet3":::

The following example shows how to iterate through the contents of a zip archive and extract files that have a .txt extension.

:::code language="csharp" source="~/snippets/csharp/System.IO.Compression/ZipArchive/Entries/program1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.io.compression.ziparchive/vb/program1.vb" id="Snippet1":::

:::code language="vb" source="~/snippets/visualbasic/System.IO.Compression/ZipArchive/Entries/program1.vb" id="Snippet1":::
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net481</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Option Strict On

Public Class Form1

Public Shared Sub Main()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' SetFormTitle()
' SetFormIcon()
Expand Down Expand Up @@ -80,7 +84,7 @@ Public Class Form1

'<snippet4>
Sub PlayFormGreeting()
My.Computer.Audio.Play(My.Resources.Form1Greeting,
My.Computer.Audio.Play(My.Resources.Form1Greeting,
AudioPlayMode.Background)
End Sub
'</snippet4>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net481-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Resources.Extensions" Version="9.0.7" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net481-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ Option Strict On

Public Class Form1

Dim loginForm As LoginForm1

Public Shared Sub Main()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' <snippet4>
My.Forms.LoginForm1.ShowDialog()
loginForm.ShowDialog()
' Check if the user was authenticated.
If My.User.IsAuthenticated Then
Me.Label1.Text = "Authenticated " & My.User.Name
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net481-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Resources.Extensions" Version="9.0.7" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
Option Strict On
Option Explicit On
Imports System.Windows.Forms

Class Class1
Public Shared Sub Main()
End Sub

Public Sub testClock()
'<snippet21>
MsgBox("Current local time: " & My.Computer.Clock.LocalTime)
Expand All @@ -18,18 +22,18 @@ Class Class1
Loop
End Sub

Private Function IsTimeUp(
ByVal startTicks As Integer,
ByVal seconds As Integer
Private Function IsTimeUp(
ByVal startTicks As Integer,
ByVal seconds As Integer
) As Boolean
' This function throws an overflow exception if the
' tick count difference is greater than 2,147,483,647,
' about 24 days for My.Computer.Clock.TickCount.

' Use UInteger to simplify the code for roll over.
Dim uStart As UInteger =
Dim uStart As UInteger =
CUInt(CLng(startTicks) - Integer.MinValue)
Dim uCurrent As UInteger =
Dim uCurrent As UInteger =
CUInt(CLng(My.Computer.Clock.TickCount) - Integer.MinValue)

' Calculate the tick count difference.
Expand All @@ -52,50 +56,50 @@ Class Class1

'<snippet17>
Sub PlaySystemSound()
My.Computer.Audio.PlaySystemSound(
My.Computer.Audio.PlaySystemSound(
System.Media.SystemSounds.Asterisk)
End Sub
'</snippet17>

'<snippet16>
Sub PlayBackgroundSoundResource()
My.Computer.Audio.Play(My.Resources.Waterfall,
My.Computer.Audio.Play(My.Resources.Waterfall,
AudioPlayMode.WaitToComplete)
End Sub
'</snippet16>

'<snippet15>
Sub PlayBackgroundSoundFile()
My.Computer.Audio.Play("C:\Waterfall.wav",
My.Computer.Audio.Play("C:\Waterfall.wav",
AudioPlayMode.WaitToComplete)
End Sub
'</snippet15>

'<snippet14>
Sub PlaySoundResource()
My.Computer.Audio.Play(My.Resources.Waterfall,
My.Computer.Audio.Play(My.Resources.Waterfall,
AudioPlayMode.WaitToComplete)
End Sub
'</snippet14>

'<snippet13>
Sub PlaySoundFile()
My.Computer.Audio.Play("C:\Waterfall.wav",
My.Computer.Audio.Play("C:\Waterfall.wav",
AudioPlayMode.WaitToComplete)
End Sub
'</snippet13>

'<snippet12>
Sub PlayLoopingBackgroundSoundResource()
My.Computer.Audio.Play(My.Resources.Waterfall,
My.Computer.Audio.Play(My.Resources.Waterfall,
AudioPlayMode.BackgroundLoop)
End Sub
'</snippet12>

'<snippet19>
'<snippet11>
Sub PlayLoopingBackgroundSoundFile()
My.Computer.Audio.Play("C:\Waterfall.wav",
My.Computer.Audio.Play("C:\Waterfall.wav",
AudioPlayMode.BackgroundLoop)
End Sub
'</snippet11>
Expand All @@ -121,35 +125,35 @@ Class Class1
MsgBox("Computer name: " & My.Computer.Name)
'</snippet1>
'<snippet2>
MsgBox("Computer's available physical memory: " &
MsgBox("Computer's available physical memory: " &
My.Computer.Info.AvailablePhysicalMemory)
'</snippet2>
'<snippet3>
MsgBox("Computer's available virtual memory: " &
MsgBox("Computer's available virtual memory: " &
My.Computer.Info.AvailableVirtualMemory)
'</snippet3>
'<snippet4>
MsgBox("Computer's UI culture name: " &
MsgBox("Computer's UI culture name: " &
My.Computer.Info.InstalledUICulture.DisplayName)
'</snippet4>
'<snippet5>
MsgBox("Computer's operating system name: " &
MsgBox("Computer's operating system name: " &
My.Computer.Info.OSFullName)
'</snippet5>
'<snippet6>
MsgBox("Computer's operating system platform: " &
MsgBox("Computer's operating system platform: " &
My.Computer.Info.OSPlatform)
'</snippet6>
'<snippet7>
MsgBox("Computer's operating system version: " &
MsgBox("Computer's operating system version: " &
My.Computer.Info.OSVersion)
'</snippet7>
'<snippet8>
MsgBox("Computer's available physical memory: " &
MsgBox("Computer's available physical memory: " &
My.Computer.Info.TotalPhysicalMemory)
'</snippet8>
'<snippet9>
MsgBox("Computer's available virtual memory: " &
MsgBox("Computer's available virtual memory: " &
My.Computer.Info.TotalVirtualMemory)
'</snippet9>

Expand Down
Loading