/// <summary> /// �ҵ���һ���ļ���Ŀ¼ /// </summary> /// <returns>�����Ƿ�ɹ�</returns> public bool MoveNext() { bool success = false; while (true) { if (this.bolStartSearchFlag) success = this.SearchNext(); else success = this.StartSearch(); if (success) { if (this.UpdateCurrentObject()) { //���µ�ǰ�ļ����� this.currentFileData = new FindFileData(myData, this.strSearchPath, this.bolIsFile); return true; } } else { return false; } } }
/// <summary> /// 处理找到的文件数据,将文件数据转成文件信息。 /// </summary> private void DealFindData() { DateTime dt1 = DateTime.Now; this.isDealDataEnd = false; FindFileData findFileData = new FindFileData(); FileData fileData = new FileData(); bool isQueueEmpty = true; while (true) { //如果用户执行了停止索引,结束。 if (this.isStopIndexFile == true) break; lock (this.findFileDataQueue) { if (this.findFileDataQueue.Count > 0) { isQueueEmpty = false; findFileData = this.findFileDataQueue.Dequeue(); } else { isQueueEmpty = true; } } if (isQueueEmpty == false) { fileData.Name = findFileData.name; fileData.Directory = findFileData.directory; if (findFileData.isFile) { fileData.Length = Deal.ToLong(findFileData.nFileSizeHigh, findFileData.nFileSizeLow).ToString(); fileData.Extension = Deal.GetExtension(fileData.Name);//扩展名 } else { fileData.Length = "-1";//文件夹标志 fileData.Extension = ".f";//文件夹 } fileData.LastWriteTime = Deal.ToDateTimeString(findFileData.ftLastWriteTime_dwHighDateTime, findFileData.ftLastWriteTime_dwLowDateTime); lock (this.fileDataQueue) { this.fileDataQueue.Enqueue(fileData); } } else if (this.isScanFileEnd == false) { //Console.Out.WriteLine("FindFileDataQueue 空"); Thread.Sleep(0);//让出时间片给其他线程 continue; } else { break; } } this.isDealDataEnd = true;//处理数据结束 double d = (DateTime.Now - dt1).TotalSeconds; //Console.Out.WriteLine("处理" + d); }