Beispiel #1
0
        private void ProcessDirectoryDataCallBack(object state)
        {
            BackupFolder  bc = state as BackupFolder;
            DirectoryData dc = new DirectoryData();

            ThreadPoolQueueUsage++;

            lock (workItemsThreadLock)
            {
                currentWorkItems.Add(bc.UniqueId);
            }

            ComputeDirecoryData(bc.Directory, dc, bc.UniqueId);

            bc.Files         = dc.FilesTotal;
            bc.DataSize      = dc.TotalFileSize;
            bc.SubFolders    = dc.SubDirectories;
            bc.RequireUpdate = false;
            bc.TriggerFullUpdate();
            ThreadPoolQueueUsage--;

            if (workerThread.ThreadState == ThreadState.WaitSleepJoin && ThreadPoolQueueUsage < MaxThreadPoolQueue)
            {
                threadPoolResetEvent.Set();
            }
        }
Beispiel #2
0
        private void ComputeDirecoryData(string path, DirectoryData dc, ulong uniqueId)
        {
            lock (workItemsThreadLock)
            {
                if (!currentWorkItems.Contains(uniqueId))
                {
                    return;
                }
            }

            DirectoryInfo directoryInfo = new DirectoryInfo(path);

            if (accessHelper.UserHasReadAccessToDirectory(directoryInfo))
            {
                FileInfo[] directoryFiles;
                try
                {
                    directoryFiles = directoryInfo.GetFiles();
                }
                catch (Exception ex)
                {
                    LogWriter.WriteLog("Error in class DirectoryData.GetDirecoryData() - " + ex.Message);
                    return;
                }
                dc.FilesTotal += directoryInfo.GetFiles().Length;

                foreach (FileInfo di in directoryFiles)
                {
                    dc.TotalFileSize += di.Length;
                }

                DirectoryInfo[] subDirectories = directoryInfo.GetDirectories();
                dc.SubDirectories += subDirectories.Length;

                foreach (DirectoryInfo subDir in subDirectories)
                {
                    ComputeDirecoryData(subDir.FullName, dc, uniqueId);
                }
            }
        }