Thanks to visit codestin.com
Credit goes to github.com

Skip to content

My.Computer.Network.DownloadFile does not cancel immediately #10709

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

Open
paul1956 opened this issue Jan 21, 2024 · 4 comments
Open

My.Computer.Network.DownloadFile does not cancel immediately #10709

paul1956 opened this issue Jan 21, 2024 · 4 comments
Labels
area-VisualBasic priority-3 Work that is nice to have
Milestone

Comments

@paul1956
Copy link
Contributor

.NET version

Microsoft Visual Studio Community 2022 (64-bit) - Preview Version 17.9.0 Preview 3.0

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

Don't think so

Issue description

When you download a large file with a progress UI, and then cancel the request through UI the download completes and then the cancel error is thrown. Also, on Framework the partially download file is deleted and .NET Core the fully download file is left in the destination directory.

The code below is a test, it is includes and 3 PR's

      <WinFormsFact>
       Public Sub DownloadWithUI()
           Dim tmpFilePath As String = CreateTempDirectory()
           Dim destinationFilename As String = CreateTempFile(tmpFilePath, 0)
           My.Computer.Network.DownloadFile("https://ash-speed.hetzner.com/100MB.bin",
                                            destinationFilename,
                                            "",
                                            "",
                                            True,
                                            100000,
                                            True
                                           )
           Assert.Equal(ValidateDownLoad(tmpFilePath, destinationFilename), 104857600)
           CleanupTempDirectory(tmpFilePath)
       End Sub

Steps to reproduce

Download a large file with UI using My.Computer.Network.DownloadFile and the cancel operation.
Download will complete before CancelOperation is thrown and resulting file is in destination directory, in Framework cancel is immediate and file is deleted.

@paul1956 paul1956 added the untriaged The team needs to look at this issue in the next triage label Jan 21, 2024
@paul1956 paul1956 changed the title My.Computer.Network.DownloadFile down not cancel immediately My.Computer.Network.DownloadFile does not cancel immediately Jan 21, 2024
@merriemcgaw merriemcgaw added this to the .NET 9.0 milestone Jan 23, 2024
@merriemcgaw merriemcgaw removed the untriaged The team needs to look at this issue in the next triage label Jan 23, 2024
@merriemcgaw
Copy link
Member

Thanks for filing this! @KlausLoeffelmann may be able to offer some suggestions as you go forward.

@merriemcgaw merriemcgaw added the priority-3 Work that is nice to have label Jan 23, 2024
@paul1956
Copy link
Contributor Author

@merriemcgaw I have fixed this is my PR #9867, but it is broken in .Net Core compared to Framework.

@JeremyKuhne JeremyKuhne modified the milestones: .NET 9.0, Future Jul 24, 2024
@paul1956
Copy link
Contributor Author

paul1956 commented May 8, 2025

@merriemcgaw if this isn't going to ever be fixed the documentation should be updated with new behaviors and PR closed.

There are 2 breaking changes

  1. Cancel does not stop Network File upload and download operations though the UI is unresponsive.

  2. Operation completes and files are left (not deleted) both for upload on server and download on client where on .Net they are deleted.

@merriemcgaw
Copy link
Member

@KlausLoeffelmann do you think this makes more sense as a breaking (between NetFX and Core) change that is documented, or do you think a fix is the better answer for .NET 10?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VisualBasic priority-3 Work that is nice to have
Projects
None yet
Development

No branches or pull requests

4 participants