Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2666,12 +2666,6 @@ private void CreateDirectory(string path, bool streamOutput)
!string.IsNullOrEmpty(path),
"The caller should verify path");

// Get the parent path
string parentPath = GetParentPath(path, null);

// The directory name
string childName = GetChildName(path);

ErrorRecord error = null;
if (!Force && ItemExists(path, out error))
{
Expand Down Expand Up @@ -2701,7 +2695,7 @@ private void CreateDirectory(string path, bool streamOutput)

if (ShouldProcess(resource, action))
{
var result = Directory.CreateDirectory(Path.Combine(parentPath, childName));
var result = Directory.CreateDirectory(path);

if (streamOutput)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,20 @@ Describe "Extended FileSystem Item/Content Cmdlet Provider Tests" -Tags "Feature
$result.Name | Should -BeExactly $testDir
}

It "Verify Directory creation when path relative to current PSDrive is empty" {
try {
$rootDir = New-Item "NewDirectory" -ItemType Directory -Force
$rootPath = $rootDir.FullName
$newPSDrive = New-PSDrive -Name "NewPSDrive" -PSProvider FileSystem -Root $rootPath

$result = New-Item -Path "NewPSDrive:\" -ItemType Directory -Force
$result.FullName.TrimEnd("/\") | Should -BeExactly $newPSDrive.Root
}
finally {
Remove-PSDrive -Name "NewPSDrive" -Force -ErrorAction SilentlyContinue
}
}

It "Verify File + Value" {
$result = New-Item -Path . -ItemType File -Name $testFile -Value "Some String"
$content = Get-Content -Path $testFile
Expand Down
Loading