Search for images using C # in a folder with local images

We have a folder with images, which contains about a million images. We need to write a program that will extract an image based on a keyword entered by the user. We need to match the file names during the search to find the correct image. Look for any suggestions. thanks N

+3
source share
9 answers

Depending on your operating system, I suggest you use the indexing service, Windows Desktop Search, or the latest version of Windows Search. This solves your keyword-based file search problem, eliminates performance issues regarding the number of files in a folder, scales and easily extends.

The DSearch example at http://msdn.microsoft.com/en-us/library/dd940335(VS.85).aspx does almost what you want and is easy to implement.

For example, if you request a million files and you need to move the file to subfolders to increase performance, you can simply create folders and move files. You will not need to change the code.

If you need to change the way you apply keywords, for example, use keywords for file summary properties, you only need to change the query.

- , OleDB. (AQS), Microsoft COM, SQL .

, .. - .

+2
  • . , , , 1M , .

  • ( ) :

    ImageFile  
        ID  
        Filepath

    Keyword
        ID
        theWord

    ImageKeyword
        ImageID
        KeywordID
+4

( ) .

.

( , ..), ( ) .

, , , , .

+2

, , :

public IList<string> GetMatchingImages(string path, string keyword)
    {
        var matches = new List<string>();

        var images = System.IO.Directory.GetFiles(path);

        foreach (var image in images)
        {
            if (image.Contains(keyword))
            {
                matches.Add(image);
            }
        }

        return matches;
    }
+2

. . , .

+1

Win32 API FindFirstFile, FindNextFile, FindClose: http://msdn.microsoft.com/en-us/library/aa364418(VS.85).aspx - , - .NET. - .

0

, .

, , , , , .

.

0

, , varchar (string), . ( )

, , .

0

, . .

, .

0

Source: https://habr.com/ru/post/1750245/


All Articles