mCleaner.Logics.Commands.CommandLogic_Delete.IsWhitelisted C# (CSharp) Method

IsWhitelisted() public method

public IsWhitelisted ( string path ) : bool
path string
return bool
        public bool IsWhitelisted(string path)
        {
            bool ret = false;
            StringCollection lists = Settings.Default.WhitelistCollection;

            if (lists == null) return false;

            foreach (string f in lists)
            {
                ret = false;
                if (File.Exists(f))
                {
                    if (path.ToLower() == f.ToLower()) { ret = true; break; }
                }
                else if (Directory.Exists(f))
                {
                    // eg
                    // whitelisted directory: C:\Users\Administrator\AppData\Local\Temp\ALM
                    // path to be deleted   : C:\Users\Administrator\AppData\Local\Temp\ALM\ShadowCopies\d926192406574f99b57077a37efb88b7
                    if (f.Length <= path.Length)
                    {
                        string p = path.Substring(0, f.Length);

                        // p will be            : C:\Users\Administrator\AppData\Local\Temp\ALM
                        if (p.ToLower() == f.ToLower())
                        {
                            ret = true;
                            break;
                        }
                    }
                }
            }

            return ret;
        }