glob icon indicating copy to clipboard operation
glob copied to clipboard

Consider use of System.IO.Enumeration

Open danmoseley opened this issue 7 years ago • 10 comments

In .NET Core 2.1 there's a "advanced" file system enumeration API https://blogs.msdn.microsoft.com/jeremykuhne/2018/03/09/custom-directory-enumeration-in-net-core-2-1/ that is faster and more customizable.

Perhaps this would be interesting to use if available, especially since .NET Core itself does not yet have advanced globbing functionality.

danmoseley avatar Jul 27 '18 17:07 danmoseley

This seems like a good suggestion. I would be open to discussing an implementation/API for this and greatly appreciation any contributions.

kthompson avatar Aug 15 '18 02:08 kthompson

This seems interesting but until these APIs are available in .NET standard I don't think it make sense for this project at this time. Thanks

kthompson avatar Oct 27 '18 23:10 kthompson

Makes sense. It's expected in.NET Standard 2.1: https://github.com/dotnet/standard/pull/820

danmoseley avatar Oct 27 '18 23:10 danmoseley

I am subscribed to that PR 😄 I will keep an eye on it.

kthompson avatar Oct 28 '18 00:10 kthompson

@danmosemsft I was looking at the code for the System.IO.Enumeration APIs and I noticed that there are bits of code like:

#if MS_IO_REDIST
namespace Microsoft.IO.Enumeration
#else
namespace System.IO.Enumeration
#endif

As far as I can tell those allow usage from .NET Framework 4.7.2. Is that correct? If I wanted to use the file system enumeration API in .NET Framework 4.7.2 would I need to add a package for Microsoft.IO.Redist?

kthompson avatar Mar 11 '20 02:03 kthompson

I think so - looks like it's in nuget. https://www.nuget.org/packages/Microsoft.IO.Redist

Since our focus is.NET Core if you found a bug that was specific to.NET Framework we might not be able to fix it, but it's open source and as far as I know it would work fine. @jeremykuhne owns this - Jeremy any known issues with the package on.NET Framework?

danmoseley avatar Mar 11 '20 02:03 danmoseley

@kthompson No known issues. :) That package is specifically for 4.7.2. Let me know if you have any problems with it.

JeremyKuhne avatar Mar 11 '20 19:03 JeremyKuhne

@JeremyKuhne the only thing I noticed is that all of the FileSystemInfo, DirectoryInfo, and FileInfo seemed to be from another namespace as well. Something like Microsoft.IO.FileInfo iirc. Is that to be expected? I was looking at incorporating the use of System.IO.Enumeration but I wanted to keep support for .NET Framework as well but it seemed odd to me that those types have a different namespace rather than the same one from .NET Framework(making them effectively different types).

kthompson avatar Mar 11 '20 19:03 kthompson

@kthompson that is by design as they are different types. The library doesn't include everything in System.IO- the key thing it doesn't have is FileStream. FileStream on 4.7.2 will work with long paths and the like- you can either manifest and enable the reg key in Windows or simply prepend with \\?\ when creating FileStreams (after calling M.IO.Path.GetFullPath()).

JeremyKuhne avatar Mar 11 '20 19:03 JeremyKuhne

@JeremyKuhne Ok. I don't think it will be a major issue for users of this library on .NET Framework to use Microsoft.IO.Redist as there will be a couple breaking changes anyways. I will just need to make the ifdefs to use M.IO rather than System.IO for .NET Framework. Thanks for the feedback.

kthompson avatar Mar 11 '20 19:03 kthompson