Skip to content
This repository was archived by the owner on Aug 8, 2024. It is now read-only.

Commit bff1d77

Browse files
author
Martin Baulig
authored
Merge pull request #388 from steveisok/backport-dir-create-invalidate
Invalidate DirectoryInfo After Create
2 parents cfbc19d + afff764 commit bff1d77

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ public DirectoryInfo CreateSubdirectory(string path)
8282
throw new ArgumentException(SR.Format(SR.Argument_InvalidSubPath, path, FullPath), nameof(path));
8383
}
8484

85-
public void Create() => FileSystem.CreateDirectory(FullPath);
85+
public void Create()
86+
{
87+
FileSystem.CreateDirectory(FullPath);
88+
Invalidate();
89+
}
8690

8791
// Returns an array of Files in the DirectoryInfo specified by path
8892
public FileInfo[] GetFiles() => GetFiles("*", enumerationOptions: EnumerationOptions.Compatible);

src/System.IO.FileSystem/tests/DirectoryInfo/Create.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,14 @@ public void UnixLastDotIsExtension(string extension, string trailing)
7474
DirectoryInfo testInfo = new DirectoryInfo(testDir + extension + trailing);
7575
Assert.Equal(trailing, testInfo.Extension);
7676
}
77+
78+
[Fact]
79+
public void CreateDirectoryWithAttributes()
80+
{
81+
string testDir = Path.Combine(GetTestFilePath(), "CreateDirectoryWithAttributes");
82+
DirectoryInfo testInfo = new DirectoryInfo(testDir);
83+
testInfo.Create();
84+
testInfo.Attributes = FileAttributes.Directory | FileAttributes.Normal;
85+
}
7786
}
7887
}

0 commit comments

Comments
 (0)