Skip to content
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

Compress-Archive: Please don't open Source-Files with FileShare:None #37

Closed
schittli opened this issue Apr 30, 2017 · 2 comments · Fixed by #131
Closed

Compress-Archive: Please don't open Source-Files with FileShare:None #37

schittli opened this issue Apr 30, 2017 · 2 comments · Fixed by #131

Comments

@schittli
Copy link

schittli commented Apr 30, 2017

Good evening

If we try to Compress a directory which has locked files (e.g. C:\Portable\KeePass\KeePass.XmlSerializers.dll), then we get an "Access Denied" exception.

It's completely save to backup such files, therefore please change in Microsoft.PowerShell.Archive.psm1

$currentFileStream = [System.IO.File]::Open($currentFilePath, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read)

to
$currentFileStream = [System.IO.File]::Open($currentFilePath, [System.IO.FileMode]::Open, [System.IO.FileAccess]::Read, [System.IO.FileShare]::Read)

so that Compress-Archive does not expect to get exclusive access to the source files.

Thanks a lot, kind regards, Thomas

@SteveL-MSFT
Copy link
Member

@schittli perhaps you could submit the change as a PR with a test? Thanks!

@ayousuf23
Copy link
Contributor

This is fixed.

@ayousuf23 ayousuf23 linked a pull request Aug 18, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants