如何在Windows系统中搜索任何数据 [英] how to search a any data in windows System

查看:68
本文介绍了如何在Windows系统中搜索任何数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用c#:confused:搜索逻辑以在System中缓存任何文件.
例如. Windows xp中的搜索选项.

I want to search logic for seaching any file in System using c#:confused:.
E.g. Search option in windows xp.

推荐答案

请参阅此msdn文章,该文章完全符合您的要求:
http://support.microsoft.com/kb/303974/EN-US [ ^ ]
See this msdn article that does exactly what you want:
http://support.microsoft.com/kb/303974/EN-US[^]


此处"是一个例子
http://www.csharp-examples.net/get-files-from-directory/ [< ^ ]

欢呼声
Here''s an example
http://www.csharp-examples.net/get-files-from-directory/[^]

Cheers


public static void Search(string dirpath, string searchpattern)
        {
            // 'dirpath' shoud be any path like "C:\\documents\\" or "D:\\temp" etc
            // 'searchpattern' is nothing should be *.txt or *.xml or *.* and so-on
            string[] sFiles = Directory.GetFiles(dirpath, searchpattern);
            foreach (string sFile in sFiles)
            {
                // Result files for the search pattern will be here ....
            }
            string[] sDirs = Directory.GetDirectories(dirpath);
            foreach (string sdir in sDirs)
            {
                // This method will Recursive do check to the sub directories. with the same search pattern
                Search(sdir, searchpattern);
            }
        }


这篇关于如何在Windows系统中搜索任何数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆