You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When creating file using -Path c: without a backslash, file created in the drive root and not in the current folder. #7048
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
>$PSVersionTable
Name Value
---------
PSVersion 6.1.0-preview.705
PSEdition Core
GitCommitId v6.1.0-preview.705
OS Microsoft Windows 10.0.17134
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Sergey Vasin (@sethvs) - I Don't think this is an issue as this is expected behaviour because you are telling New-item to create the file in the C: directory
If you leave off -Path C: it will create that file in the current directory which in this case is C:\Folder
Ryan Yates (@kilasuit) It is not the expected behavior, because it worked the way I specified in version 6.1.0-preview.2 and earlier.
This was changed in #6774, I believe.
Sergey Vasin (@sethvs) - I think this is expected behaviour and your use is more of an incorrect edge use case than being an actual issue - because you are explicitly telling New-Item what Path you want it to create in which is C: - as far as i know this is how New-Item has worked since v3 and whist it never crosses my mind to ever use drive directories without the slash this I don't think is unexpected behaviour in the slightest
this will create the file in C:\folder1\folder2\ which is in my opinion exactly as it was designed to do so and ergo is the designed and expected behaviour.
C:\Folder>dir c:\
Volume in drive C has no label.
Volume Serial Number
Directory of c:\
06/13/2018 11:02 AM <DIR> Program Files
05/30/2018 09:08 AM <DIR> Program Files (x86)
12/28/2017 04:25 PM <DIR> Temp
05/13/2018 05:43 PM <DIR> Users
05/13/2018 06:00 PM <DIR> Windows
etc...
while dir c: lists current folder
C:\Folder>dir c:
Volume in drive C has no label.
Volume Serial Number
Directory of C:\Folder
06/14/2018 12:32 PM <DIR> .
06/14/2018 12:32 PM <DIR> ..
06/14/2018 12:32 PM 0 testfile.txt
1 File(s) 0 bytes
2 Dir(s)
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
Activity
kilasuit commentedon Jun 12, 2018
Sergey Vasin (@sethvs) - I Don't think this is an issue as this is expected behaviour because you are telling New-item to create the file in the C: directory
If you leave off
-Path C:it will create that file in the current directory which in this case isC:\Foldersethvs commentedon Jun 13, 2018
Ryan Yates (@kilasuit) It is not the expected behavior, because it worked the way I specified in version 6.1.0-preview.2 and earlier.
This was changed in #6774, I believe.
kilasuit commentedon Jun 13, 2018
Sergey Vasin (@sethvs) - I think this is expected behaviour and your use is more of an incorrect edge use case than being an actual issue - because you are explicitly telling New-Item what Path you want it to create in which is
C:- as far as i know this is how New-Item has worked since v3 and whist it never crosses my mind to ever use drive directories without the slash this I don't think is unexpected behaviour in the slightestif you had
this will create the file in
C:\folder1\folder2\which is in my opinion exactly as it was designed to do so and ergo is the designed and expected behaviour.However if you do this
this creates this in the folder2 directory as intended
also take this example
You would not expect a ps1 file to be created in HKLM - or would you?
iSazonov commentedon Jun 14, 2018
I'd add that the behavior came from cmd.exe -dir c:works asdir c:\.sethvs commentedon Jun 14, 2018
Guys, please pay attention:
Windows PowerShell 5.1: file is created in current path - C:\Folder
PowerShell Core 6.0.2: file is created in current path - C:\Folder
PowerShell Core 6.1.0-preview.2: file is created in current path - C:\Folder
PowerShell Core 6.1.0-preview.3: file is created in root path - C:\
Again, this was changed with PR #6774.
My fix for this is in #7033.
sethvs commentedon Jun 14, 2018
Ilya (@iSazonov) Nope.
dir c:\lists the root of the drivewhile
dir c:lists current folderiSazonov commentedon Jun 14, 2018
Sergey Vasin (@sethvs) Please update the PR description with the samples..
sethvs commentedon Jun 14, 2018
Ilya (@iSazonov) Done.