Skip to content

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

Closed
@schittli

Description

@schittli

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions