Giter Club home page Giter Club logo

Comments (1)

preiius avatar preiius commented on September 4, 2024 1

I know this is not exactly what you want, but I made a few changes to exclude folders (not files) from an exclude file.

  1. Add nuget package DotNet.Glob at https://www.nuget.org/packages/DotNet.Glob/3.0.9

  2. frmMain.cs

public partial class frmMain : Form
{
    ...

    private void frmMain_Load( object sender, EventArgs e )
    {
        ...

        if( System.IO.Directory.Exists( txtRoot.Text ) )
        {
            SetRootPath( txtRoot.Text , true);
        }
        else
        {
            SetRootPath( "" , false );
        }

        LoadExcludeFolders();

        txtLinkRoot.Enabled = chkLinkFiles.Checked;

        ...
  1. frmMain_Helpers.cs
public partial class frmMain : Form
{
    private static List<Glob> _globs = new List<Glob>();

    private void LoadExcludeFolders()
    {
        GlobOptions.Default.Evaluation.CaseInsensitive = true;

        string line;
        using (var streamReader = new StreamReader(@"Exclude_List.txt"))
        {
            while ((line = streamReader.ReadLine()) != null)
            {
                if (string.IsNullOrWhiteSpace(line)) continue;

                _globs.Add(Glob.Parse(line));
            }
        }
    }

   ...

    // Recursive function to get all folders and subfolders of given path path
    public void DirSearch( string sDir, List<string> lstDirs, bool skipHidden, bool skipSystem, Stopwatch stopwatch )
    {
        if( backgroundWorker.CancellationPending ) return;

        try
        {
            foreach( string d in System.IO.Directory.GetDirectories( sDir ) )
            {
                bool includeThisFolder = true;

                foreach (var glob in _globs)
                {
                    if ( glob.IsMatch(d) )
                    {
                        includeThisFolder = false;
                        break;
                    }
                }

                // exclude folders that have the system or hidden attr set (if required)
                if ( skipHidden || skipSystem )
                {
                    ...
  1. Add the exclude file named Exclude_List.txt in same folder containing exe.

Use glob pattern to specify folders. For example:

**\node_modules

will exclude any node_modules folders. ** matches any number of subfolders.

from snap2html.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.