gsemac / Gsemac.Common

A collection of .NET utilities for use across my projects
MIT License
7 stars 3 forks source link

Add utilities for working with long paths #5

Open gsemac opened 2 years ago

gsemac commented 2 years ago

Prior to .NET Framework 4.6.2, there was no support for paths longer than MAX_PATH in the managed IO classes. Apps running on .NET Framework 4.6.2 or later that target earlier versions of .NET Framework are able to bypass MAX_PATH with a bit of work, requiring the user to opt-in via registry key and the application via its manifest.

If .NET Framework 4.6.2 or later is not available, the restriction can be bypassed by P/Invoking the relevant Win32 APIs directly with using the long path prefix (\\?\).

It would be nice to allow for long paths to be used transparently, probably by adding some methods to FileUtilities.