mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Merged PR 3115: Use Directory.CreateDirectory instead of DirectoryInfo.CreateSubDirectory
Change to use Directory.CreateDirectory because of regression introduced by https://github.com/dotnet/corefx/pull/27810 in creating a subdirectory under root path.
This commit is contained in:
@@ -2599,10 +2599,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
if (ShouldProcess(resource, action))
|
||||
{
|
||||
// Use the parent directory to create the sub-directory
|
||||
|
||||
DirectoryInfo parentDirectory = new DirectoryInfo(parentPath);
|
||||
DirectoryInfo result = parentDirectory.CreateSubdirectory(childName);
|
||||
var result = Directory.CreateDirectory(Path.Combine(parentPath, childName));
|
||||
|
||||
if (streamOutput)
|
||||
{
|
||||
|
||||
@@ -1396,3 +1396,21 @@ Describe "Remove-Item UnAuthorized Access" -Tags "CI", "RequireAdminOnWindows" {
|
||||
Get-Content $errorFile | Should -BeExactly 'RemoveItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.RemoveItemCommand'
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Verify sub-directory creation under root" -Tag 'CI','RequireSudoOnUnix' {
|
||||
BeforeAll {
|
||||
$dirPath = "\TestDir-$((New-Guid).Guid)"
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
if(Test-Path $dirPath)
|
||||
{
|
||||
Remove-Item -Path $dirPath -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
It "Can create a sub directory under root path" {
|
||||
New-Item -Path $dirPath -ItemType Directory -Force > $null
|
||||
$dirPath | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user