Beispiel #1
0
        private void CheckAllInFolder(string folderPath)
        {
            DirectoryInfo theFolder = new DirectoryInfo(folderPath);

            DirectoryInfo[] HasFolders = theFolder.GetDirectories();
            FileInfo[]      HasFiles   = theFolder.GetFiles();

            if (theFolder == null)
            {
                return;
            }
            else
            {
                if (HasFiles.Length != 0)
                {
                    foreach (var nextFile in HasFiles)
                    {
                        Console.WriteLine($"Start Read File Info {nextFile}");
                        MCPFileInfo theFileInfo = new MCPFileInfo()
                        {
                            Id   = this.Id++,
                            Name = nextFile.Name,
                            //FullName = nextFile.FullName,
                            //Directory = nextFile.DirectoryName,
                            LastModifyTime = nextFile.LastWriteTime,
                            Size           = string.Concat(nextFile.Length.ToString(), " bytes"),
                        };

                        if (!excludedExtensions.Contains(nextFile.Extension.ToLower()))
                        {
                            theFileInfo.Content = nextFile.Length < 2000000 ? GetFileContent(nextFile) : "File is too large...";
                        }
                        else
                        {
                            theFileInfo.Content = string.Empty;
                        };

                        client.SaveMCPFileInfo(theFileInfo);
                        Console.WriteLine($"Send File Info {nextFile} to ElasticSearch Successfully");
                    }
                }

                if (HasFolders.Length != 0)
                {
                    foreach (var NextFolder in HasFolders)
                    {
                        CheckAllInFolder(NextFolder.FullName);
                    }
                }
                else
                {
                    return;
                }
            }
        }
Beispiel #2
0
 public void SaveMCPFileInfo(MCPFileInfo fileInfo)
 {
     var response = _client.IndexDocument(fileInfo);
     //Console.WriteLine(response.DebugInformation);
 }