如何搜索文件 [英] how to search a file

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

问题描述

当我在文本框中键入单词时,它应该在系统中搜索并在列表框中显示它...
请有人帮我吗?

when i type a word in textbox it should search in system and display it in listbox ...
please can any one help me

推荐答案

没人会为您做所有的编码……您必须开始自己编码.尽管我确信至少有一篇Code Project文章随附了完全符合您想要的功能的源代码.但是,我不会(也不应该有其他人)那样搜索您.
Nobody is going to do all that coding for you... you have to start coding yourself. Although I am sure there is at least one Code Project article that comes with source code that does exactly what you want. But I''ll not (nor should anybody else) do that searching for you.


您尝试了什么?为什么要做Windows已经做的事情?

您可以使用System.IO命名空间查找连接的驱动器(使用DriveInfo),然后使用Directory类搜索每个目录以查找要递归的子目录以及每个文件中的所有文件的名称.如果要匹配文件名,则可以进行字符串匹配,也可以使用File.ReadAllText来读取文件并在其中搜索要匹配的内容(我假设您的意思是仅匹配文本,而不是二进制内容)
What have you tried ? Why do you want to do what Windows does already ?

You can use the System.IO namespace to find the connected drives ( with DriveInfo ), then use the Directory class to search each directory to find subdirectories to recurse, and the names of all the files in each. You can do a string match if you want to match a filename, or File.ReadAllText to read the file and search it for the content you want to match ( I assume you mean only to match text, not binary content )


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

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