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:
Aditya Patwardhan
2018-06-11 23:06:08 +00:00
parent f08a031f88
commit 0d67d4dc3a
2 changed files with 19 additions and 4 deletions
@@ -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
}
}