예제 #1
0
 /// <summary>
 /// The InistialseFolder event is raised from here, for every subfolder that we perform an item count on.
 /// </summary>
 /// <param name="folderName">The name of the folder</param>
 /// <remarks>This event just publishes some activity to clients of this type, during the process of
 /// finding the total item count for all items</remarks>
 private void RaiseInitialScanEvent(string folderName)
 {
     if (InitialiseFolder != null)
     {
         FSScanEventArgs args = new FSScanEventArgs();
         args.FolderName = folderName;
         InitialiseFolder(this, args);
         Thread.Sleep(0);
     }
 }
예제 #2
0
        void m_scanFS_FileFound(object sender, FSScanEventArgs e)
        {
            lock (this)
            {
                m_filesFound++;

                if (0 < m_delay)
                {
                    System.Threading.Thread.Sleep(m_delay); //this will slow down the scanning speed for tests
                }
            }
        }
예제 #3
0
		void fileScan_OnFolderCountCompleted(object sender, FSScanEventArgs e)
		{
			m_fileCount = e.ItemsFound;
			m_eventReturned = true;
		}
예제 #4
0
 void OnFileSystemItemFound(object sender, FSScanEventArgs e)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #5
0
 int FindItemCount(DirectoryInfo directory)
 {
     int itemCount = 0;
     try
     {
         RaiseInitialScanEvent(directory.Name);
         foreach (string filter in m_searchFilters)
         {
             m_reset.WaitOne();
             if (m_isCounting == false)
                 return 0;
             itemCount += directory.GetFiles(filter).GetLength(0);
         }
         if (OnFolderCountProgress != null)
         {
             FSScanEventArgs args = new FSScanEventArgs();
             args.FolderName = directory.Name;
             args.ItemsFound = itemCount;
             OnFolderCountProgress(this, args);
         }
         DirectoryInfo[] subs = directory.GetDirectories();
         foreach (DirectoryInfo sub in subs)
         {
             itemCount += FindItemCount(sub);
         }
     }
     catch (UnauthorizedAccessException e)
     {
         System.Diagnostics.Trace.TraceError("Cannot access file/folder - " + e.Message);
     }
     return itemCount;
 }
예제 #6
0
 private void FindCountAysnc(object state)
 {
     System.Globalization.CultureInfo ci = state as System.Globalization.CultureInfo;
     if (ci != null)
     {
         Thread.CurrentThread.CurrentCulture = ci;
         Thread.CurrentThread.CurrentUICulture = ci;
     }
     int itemCount = 0;
     m_totalItems = 0;
     m_isCounting = true;
     if (OnFolderCountStart != null)
         OnFolderCountStart(this, new EventArgs());
     foreach (DirectoryInfo dir in m_directoriesToScan)
     {
         itemCount += FindItemCount(dir);
         m_reset.WaitOne();
         if (m_isCounting == false)
             return;
     }
     m_totalItems = itemCount;
     if (OnFolderCountCompleted != null)
     {
         FSScanEventArgs args = new FSScanEventArgs();
         args.FolderName = "";
         args.ItemsFound = itemCount;
         OnFolderCountCompleted(this, args);
     }
     RaiseInitialScanEvent(String.Empty);
     m_isCounting = false;
 }