Beispiel #1
0
        private void ScanDir(string directory, bool recurse)
        {
            try
            {
                string[] files            = Directory.GetFiles(directory);
                bool     hasMatchingFiles = false;
                for (int i = 0; i < files.Length; i++)
                {
                    if (!fileFilter_.IsMatch(files[i]))
                    {
                        files[i] = null;
                    }
                    else
                    {
                        hasMatchingFiles = true;
                    }
                }
                OnProcessDirectory(directory, hasMatchingFiles);
                if (alive_ && hasMatchingFiles)
                {
                    foreach (string str in files)
                    {
                        try
                        {
                            if (str != null)
                            {
                                OnProcessFile(str);
                                if (!alive_)
                                {
                                    goto Label_0098;
                                }
                            }
                        }
                        catch (Exception exception)
                        {
                            if (!OnFileFailure(str, exception))
                            {
                                throw;
                            }
                        }
                    }
                }
            }
            catch (Exception exception2)
            {
                if (!OnDirectoryFailure(directory, exception2))
                {
                    throw;
                }
            }
Label_0098:
            if (alive_ && recurse)
            {
                try
                {
                    foreach (string str2 in Directory.GetDirectories(directory))
                    {
                        if ((directoryFilter_ == null) || directoryFilter_.IsMatch(str2))
                        {
                            ScanDir(str2, true);
                            if (!alive_)
                            {
                                return;
                            }
                        }
                    }
                }
                catch (Exception exception3)
                {
                    if (!OnDirectoryFailure(directory, exception3))
                    {
                        throw;
                    }
                }
            }
        }
        private void ScanDir(string directory, bool recurse)
        {
            try
            {
                string[] files = Directory.GetFiles(directory);
                bool     flag  = false;
                for (int i = 0; i < files.Length; i++)
                {
                    if (!fileFilter_.IsMatch(files[i]))
                    {
                        files[i] = null;
                    }
                    else
                    {
                        flag = true;
                    }
                }
                OnProcessDirectory(directory, flag);
                if (alive_ && flag)
                {
                    string[] array = files;
                    foreach (string text in array)
                    {
                        try
                        {
                            if (text != null)
                            {
                                OnProcessFile(text);
                                if (!alive_)
                                {
                                    goto IL_0098;
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            if (!OnFileFailure(text, e))
                            {
                                throw;
                            }
                        }
                    }
                }
            }
            catch (Exception e2)
            {
                if (!OnDirectoryFailure(directory, e2))
                {
                    throw;
                }
            }
            goto IL_0098;
IL_0098:
            if (alive_ && recurse)
            {
                try
                {
                    string[] array = Directory.GetDirectories(directory);
                    foreach (string text2 in array)
                    {
                        if (directoryFilter_ == null || directoryFilter_.IsMatch(text2))
                        {
                            ScanDir(text2, recurse: true);
                            if (!alive_)
                            {
                                break;
                            }
                        }
                    }
                }
                catch (Exception e3)
                {
                    if (!OnDirectoryFailure(directory, e3))
                    {
                        throw;
                    }
                }
            }
        }
Beispiel #3
0
        void ScanDir(string directory, bool recurse)
        {
            try {
                string[] names    = System.IO.Directory.GetFiles(directory);
                bool     hasMatch = false;
                for (int fileIndex = 0; fileIndex < names.Length; ++fileIndex)
                {
                    if (!fileFilter_.IsMatch(names[fileIndex]))
                    {
                        names[fileIndex] = null;
                    }
                    else
                    {
                        hasMatch = true;
                    }
                }

                OnProcessDirectory(directory, hasMatch);

                if (alive_ && hasMatch)
                {
                    foreach (string fileName in names)
                    {
                        try {
                            if (fileName != null)
                            {
                                OnProcessFile(fileName);
                                if (!alive_)
                                {
                                    break;
                                }
                            }
                        }
                        catch (Exception e) {
                            if (!OnFileFailure(fileName, e))
                            {
                                throw;
                            }
                        }
                    }
                }
            }
            catch (Exception e) {
                if (!OnDirectoryFailure(directory, e))
                {
                    throw;
                }
            }

            if (alive_ && recurse)
            {
                try {
                    string[] names = System.IO.Directory.GetDirectories(directory);
                    foreach (string fulldir in names)
                    {
                        if ((directoryFilter_ == null) || (directoryFilter_.IsMatch(fulldir)))
                        {
                            ScanDir(fulldir, true);
                            if (!alive_)
                            {
                                break;
                            }
                        }
                    }
                }
                catch (Exception e) {
                    if (!OnDirectoryFailure(directory, e))
                    {
                        throw;
                    }
                }
            }
        }
Beispiel #4
0
        private void ScanDir(string directory, bool recurse)
        {
            var store = IsolatedStorageFile.GetUserStoreForApplication();

            try
            {
                string[] names = store.GetFileNames(Path.Combine(directory, "*.*"));

                bool hasMatch = false;
                for (int fileIndex = 0; fileIndex < names.Length; ++fileIndex)
                {
                    if (!fileFilter_.IsMatch(names[fileIndex]))
                    {
                        names[fileIndex] = null;
                    }
                    else
                    {
                        hasMatch = true;
                    }
                }

                OnProcessDirectory(directory, hasMatch);

                if (alive_ && hasMatch)
                {
                    foreach (string fileName in names)
                    {
                        try
                        {
                            if (fileName != null)
                            {
                                OnProcessFile(fileName);
                                if (!alive_)
                                {
                                    break;
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            if (!OnFileFailure(fileName, e))
                            {
                                throw;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (!OnDirectoryFailure(directory, e))
                {
                    throw;
                }
            }

            if (alive_ && recurse)
            {
                try
                {
                    string[] names = store.GetDirectoryNames(Path.Combine(directory, "*"));

                    foreach (string fulldir in names)
                    {
                        if ((directoryFilter_ == null) || (directoryFilter_.IsMatch(fulldir)))
                        {
                            ScanDir(fulldir, true);
                            if (!alive_)
                            {
                                break;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    if (!OnDirectoryFailure(directory, e))
                    {
                        throw;
                    }
                }
            }
        }