I am using EnumerateFiles
to get all *.md in the directory:
foreach (var mdName in Directory.EnumerateFiles(Path.Combine(BaseDirectory,
"assets/markdowns"), "*.md", SearchOption.AllDirectories))
{
// async md parser call goes here
}
I have three test files a.md
, b.md
and c.md
.
Now when I rename a.md to a1.md, EnumerateFiles
returns both old and new filename.. The result from PowerShell says I have 3 files, while EnumerateFiles returns 4 files.
I read somewhere EnumerateFiles does some kind of caching, with lazy loading? But shouldn't it invalidate cache when the file is renamed?
GetFiles / EnumerateFiles Output:
[0]: "C:\\Repos\\KiddiesBlog\\Tests\\bin\\Debug\\assets/less\\a.md"
[1]: "C:\\Repos\\KiddiesBlog\\Tests\\bin\\Debug\\assets/less\\b.md"
[2]: "C:\\Repos\\KiddiesBlog\\Tests\\bin\\Debug\\assets/less\\c.md"
[3]: "C:\\Repos\\KiddiesBlog\\Tests\\bin\\Debug\\assets/less\\_a.md"
[4]: "C:\\Repos\\KiddiesBlog\\Tests\\bin\\Debug\\assets/less\\_a1.md"
[5]: "C:\\Repos\\KiddiesBlog\\Tests\\bin\\Debug\\assets/less\\_a2.md"
[6]: "C:\\Repos\\KiddiesBlog\\Tests\\bin\\Debug\\assets/less\\_a3.md"
Turned out to be my mistake. There is an MSBuild
task responsible for creating shadow copy of the actual assets in Debug directory. It has all the previous files. VS isn't clearing the folder on Clean Solution. I guess I need to modify this task to observe the changes in source directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With