SafeTraversal 2.0.0

dotnet add package SafeTraversal --version 2.0.0                
NuGet\Install-Package SafeTraversal -Version 2.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SafeTraversal" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SafeTraversal --version 2.0.0                
#r "nuget: SafeTraversal, 2.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SafeTraversal as a Cake Addin
#addin nuget:?package=SafeTraversal&version=2.0.0

// Install SafeTraversal as a Cake Tool
#tool nuget:?package=SafeTraversal&version=2.0.0                

System.IO.SafeTraversal v2.0.0

A Feature-Rich and UnauthorizedAccessException-Free Traversal Library for files and directories for .NET framework 4.5 above. This library guarantees no exception will be thrown while traversing certain path either for files or sub directories. This library is motivated by default .NET files/directories where when we traverse directories to get files or folders and we hit unauthorized access folder, an exception will be thrown and traversal will complete unexpectedly. So far, we have to define our own logic to traverse files and folders using default methods that .NET offers. Therefore, instead of repeating the task, we offer complete library for traversal with added features in secure way. Utilizing default methods for traversal in System.IO, we wrapped everything nicely into a complete library called System.IO.SafeTraversal.


System.IO.SafeTraversal v2.0.0 comes with safer and faster query against file system than previous version (1.1.0). In this version, a few bugs were fixed. Error log will be handed to an event that users can subscribe. Unsafe asynchronous operations have been removed. And supports custom filtering that ensures no exception will be thrown although there's an exception inside custom filter. It also supports .NET Core 2.0.


Core features that we offer:

  • Support Traversal that returns IEnumerable of FileInfo, DirectoryInfo and string objects.
  • No exception will be thrown during traversal either because of UnauthorizedAccessException or other exceptions (Except if you pass in invalid parameters to certain method).
  • Support logging mechanism using event to inspect any error occured during traversal.
  • Support top level and all directories scanning.
  • Support extension methods for DirectoryInfo class.
  • Support parents traversal for files and folders.
  • Support totally safe Files Traversal mechanism for NTFS file system by utilizing Access Control Type checking. Traversal will be slower than default option, but the result (IEnumerable of FileInfo) can be used directly for IO Operations. Ensuring no Deny access within the result of traversal (For .NET framework only. .NET Core does not support this feature).

Advanced filtering features:

  • Filters by name with case sensitive and include extension properties.
  • Filters by common size. It's like windows explorer size filtering. (Empty, Tiny, Small,...Gigantic).
  • Filters by defined size. You can pass any unit that you want. Such as Bytes, KiloBytes .... PetaBytes.
  • Filters by defined size range. You can pass any unit that you want. Such as Bytes, KiloBytes .... PetaBytes.
  • Filters by date. Based on creation date, modified date, last access date.
  • Filters by date range. Based on creation date, modified date, last access date too.
  • Filters by .NET Regular Expression pattern. With option, include extension or not.
  • Filters by composite option. It's multiple search criteria. You can combine to search based on date, size, regex pattern, extension, name and so on.
  • Filters by FileAttributes.
  • Filters by custom filter. Allowing developers to create custom filter using FileInfo and DirectoryInfo classess. This custom filter is totally safe although you pass an exception inside this filter.

NOTE: We don't support System.IO.SafeTraversal v1.1.0 anymore. That project was an experimental project. We recommend to use this version (2.0.0) instead of the previous one.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 is compatible.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 2.0

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 47,217 11/19/2017
1.1.0 1,163 10/16/2017

System.IO.SafeTraversal v2.0.0 comes with safer and faster query against file system than previous version. In this version, a few bugs were fixed. Error log will be handed to an event that users can subscribe. Unsafe asynchronous operations have been removed. And supports custom filtering that ensures no exception will be thrown although there's an exception inside custom filter. It also supports .NET Core 2.0.