Open
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest version
- Search the existing issues.
Steps to reproduce
- In CMD or PowerShell, download a big file into Windows with `scp
scp "hostname:big_input_file" big_output_file
- In another PowerShell terminal, while it's downloading, try to access it:
Get-Content big_output_file -TotalCount 2KB
- See the following error:
Get-Content: The process cannot access the file 'C:\Users\Robby\Desktop\big_output_file' because it is being used by another process.
Expected behavior
I'm trying to download a big file with `scp` and read it during the download in another program. This works with `scp` in WSL, but not in Windows.
Actual behavior
In Windows, I can't read from the file because it gets locked by `scp`.
Error details
Exception :
Type : System.IO.IOException
TargetSite :
Name : CreateFile
DeclaringType : [Microsoft.Win32.SafeHandles.SafeFileHandle]
MemberType : Method
Module : System.Private.CoreLib.dll
Message : The process cannot access the file 'C:\Users\Robby\Desktop\big_output_file' because it is being
used by another process.
Source : System.Private.CoreLib
HResult : -2147024864
StackTrace :
at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access,
FileShare share, FileOptions options)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare
share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share,
FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access,
FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Microsoft.PowerShell.Commands.FileSystemContentReaderWriter.CreateStreams(String filePath, String streamName,
FileMode fileMode, FileAccess fileAccess, FileShare fileShare, Encoding fileEncoding)
at Microsoft.PowerShell.Commands.FileSystemContentReaderWriter..ctor(String path, String streamName, FileMode mode,
FileAccess access, FileShare share, Encoding encoding, Boolean usingByteEncoding, Boolean waitForChanges,
CmdletProvider provider, Boolean isRawStream)
at Microsoft.PowerShell.Commands.FileSystemProvider.GetContentReader(String path)
TargetObject : C:\Users\Robby\Desktop\big_output_file.mkv
CategoryInfo : ReadError: (C:\Users\Robby\Desktop\big_output_file:String) [Get-Content], IOException
FullyQualifiedErrorId : GetContentReaderIOError,Microsoft.PowerShell.Commands.GetContentCommand
InvocationInfo :
MyCommand : Get-Content
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 15
Line : Get-Content $env:file -TotalCount 2KB
Statement : Get-Content $env:file -TotalCount 2KB
PositionMessage : At line:1 char:1
+ Get-Content $env:file -TotalCount 2KB
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Get-Content
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
0
1
Environment data
Name Value
---- -----
PSVersion 7.4.3
PSEdition Core
GitCommitId 7.4.3
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Version
OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2
Visuals
No response