This is a migrated thread and some comments may be shown as answers.

Search string

2 Answers 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nenna
Top achievements
Rank 1
Nenna asked on 30 Oct 2019, 02:13 PM
I need to search within several thousand files within a directory for a particular string and then return those files containing the search string within a grid.  Can you provide me with an example?

2 Answers, 1 is accepted

Sort by
0
Nenna
Top achievements
Rank 1
answered on 30 Oct 2019, 02:41 PM

The code for this is below:

 public static void AddFilesToList(string sourceDir, List<string> allFiles)
        {

            string[] fileEntries = Directory.GetFiles(sourceDir);
            foreach (string fileName in fileEntries)
            {
                allFiles.Add(fileName);
            }

   
            string[] subdirectoryEntries = Directory.GetDirectories(sourceDir);
            foreach (string item in subdirectoryEntries)
            {
             
                if ((File.GetAttributes(item) & FileAttributes.ReparsePoint) != FileAttributes.ReparsePoint)
                {
                    AddFilesToList(item, allFiles);
                }
            }

        }

 

AddFilesToList(sourceFolder, allFiles);
            if (allFiles != null)
            { 
            foreach (string fileName in allFiles)
            {
                string contents = File.ReadAllText(fileName);
                if (contents.Contains(searchWord = rsdSearch.Text.Trim()))
                {
                    
                }
            }

          }

 

How do I dynamically return the files to the grid?

 

0
Eyup
Telerik team
answered on 04 Nov 2019, 11:42 AM

Hello Nenna,

 

We have a build-in control for this requirement:
https://demos.telerik.com/aspnet-ajax/fileexplorer/examples/server-sideapi/filtertextbox/defaultcs.aspx

And also it uses the grid and its functionality as its core.

I hope this will be suitable in your case.

 

Regards,
Eyup
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Nenna
Top achievements
Rank 1
Answers by
Nenna
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or