Skip to content

Commit

Permalink
Merged PR 3115: Use Directory.CreateDirectory instead of DirectoryInf…
Browse files Browse the repository at this point in the history
…o.CreateSubDirectory

Change to use Directory.CreateDirectory because of regression introduced by dotnet/corefx#27810 in creating a subdirectory under root path.
  • Loading branch information
adityapatwardhan committed Jun 11, 2018
1 parent f08a031 commit 0d67d4d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2599,10 +2599,7 @@ private void CreateDirectory(string path, bool streamOutput)

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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 0d67d4d

Please sign in to comment.