VB.NET中的DirectoryInfo.GetFiles回调 [英] Callbacks in VB.NET for DirectoryInfo.GetFiles

查看:91
本文介绍了VB.NET中的DirectoryInfo.GetFiles回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我承认,我不是VB.NET专家,我还在学习,但是已经运行了一个烦人的问题。我正在编写一个程序,必须搜索文件

系统,因此处理大量的目录和文件。我已经找到了DirectoryInfo(这很简单),但是当我调用

DirectoryInfo.GetFiles(甚至是DirectoryInfo.GetDirectories)时,它可能需要

永远。一些目录中有数千个文件。


所以,我的应用程序只是坐在那里,用户认为它被锁定了。


我正在寻找一种从GetFiles函数获取回调的方法,这样我实际上可以提供合理的进程条。我知道我可以闪现一个

进度条或其他东西,但我希望这些信息有意义。


有人能指出我正确的方向。欢迎提供示例代码,创意,任何

建议。


提前感谢您的帮助。我在询问

之前进行了搜索和搜索,但似乎无法找到我要找的东西。


Tom

OK, I admit, I am not a VB.NET expert and am still learning, but have run
into an annoying problem. I''m writing a program that has to search the file
system and therefore processes large numbers of directories and files. I''ve
figured out DirectoryInfo (it''s pretty simple), but when I invoke
DirectoryInfo.GetFiles (or even DirectoryInfo.GetDirectories), it can take
forever. Some of the directories have thousands of files in them.

So, my application just sits there and the user thinks it''s locked up.

I''m looking for a way to get a callback from the GetFiles function so that I
can actually provide a reasonable processbar. I know I could just flash up a
progress bar or something, but I want the information to be meaningful.

Can someone point me in the right direction. Sample code, ideas, any
suggestions would be welcome.

Thanks in advance for the help. I''ve searched and searched prior to asking
but can''t seem to find what I am looking for.

Tom

推荐答案

你想要做的是创建一个类,它自己创建一个线程来为你工作

。然后该线程执行委托。主要功能

类可以更新进度条。


" Tom Scales" <到**** @ softhome.net>在消息中写道

新闻:在******************** @ comcast.com ...
What you want to do is create a class that itself creates a thread to do the
work for you. This thread then executes a "delegate" function on your main
class which can update the progress bar.

"Tom Scales" <to****@softhome.net> wrote in message
news:at********************@comcast.com...
确定我承认,我不是一名VB.NET专家,我还在学习,但已经开始讨论一个烦人的问题了。我正在编写一个程序,必须搜索
文件系统,因此处理大量的目录和文件。
我已经找到了DirectoryInfo(它非常简单),但是当我调用DirectoryInfo.GetFiles(甚至是DirectoryInfo.GetDirectories)时,它可以永远占用
。一些目录中有数千个文件。

所以,我的应用程序只是坐在那里,用户认为它被锁定了。

我正在寻找为了从GetFiles函数获取回调的方法,以便
我实际上可以提供合理的进程条。我知道我可以用闪亮的
进度条或其他东西,但我希望这些信息有意义。

有人能指出我正确的方向。欢迎提供示例代码,想法和任何建议。

提前感谢您的帮助。我在
之前进行了搜索和搜索,但似乎无法找到我要找的东西。

Tom
OK, I admit, I am not a VB.NET expert and am still learning, but have run
into an annoying problem. I''m writing a program that has to search the file system and therefore processes large numbers of directories and files. I''ve figured out DirectoryInfo (it''s pretty simple), but when I invoke
DirectoryInfo.GetFiles (or even DirectoryInfo.GetDirectories), it can take
forever. Some of the directories have thousands of files in them.

So, my application just sits there and the user thinks it''s locked up.

I''m looking for a way to get a callback from the GetFiles function so that I can actually provide a reasonable processbar. I know I could just flash up a progress bar or something, but I want the information to be meaningful.

Can someone point me in the right direction. Sample code, ideas, any
suggestions would be welcome.

Thanks in advance for the help. I''ve searched and searched prior to asking but can''t seem to find what I am looking for.

Tom



*" Tom Scales" <到**** @ softhome.net> scripsit:
* "Tom Scales" <to****@softhome.net> scripsit:
好吧,我承认,我不是VB.NET专家,我还在学习,但已经运行了一个恼人的问题。我正在编写一个程序,必须搜索文件系统,因此处理大量的目录和文件。我已经找到了DirectoryInfo(它非常简单),但是当我调用DirectoryInfo.GetFiles(甚至是DirectoryInfo.GetDirectories)时,它可以永远占用
。一些目录中有数千个文件。

所以,我的应用程序只是坐在那里,用户认为它被锁定了。

我正在寻找从GetFiles函数获取回调的方法,以便我实际上可以提供合理的进程条。我知道我可以闪现一个
进度条或其他东西,但我希望这些信息有意义。
OK, I admit, I am not a VB.NET expert and am still learning, but have run
into an annoying problem. I''m writing a program that has to search the file
system and therefore processes large numbers of directories and files. I''ve
figured out DirectoryInfo (it''s pretty simple), but when I invoke
DirectoryInfo.GetFiles (or even DirectoryInfo.GetDirectories), it can take
forever. Some of the directories have thousands of files in them.

So, my application just sits there and the user thinks it''s locked up.

I''m looking for a way to get a callback from the GetFiles function so that I
can actually provide a reasonable processbar. I know I could just flash up a
progress bar or something, but I want the information to be meaningful.




你会在这里找到一个很好的样本(注意样本是用
C#编写的,必须先翻译成VB.NET才能在VB.NET中使用):


< http ://www.palmbytes.de/content/dotnetlibs/filesearchlib.htm>


-

Herfried K. Wagner [MVP]

< http://www.mvps.org/dotnet>



You will find a nice sample here (notice that the sample is written in
C# and must be translated to VB.NET before it can be used in VB.NET):

<http://www.palmbytes.de/content/dotnetlibs/filesearchlib.htm>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


我知道怎么做,但我坚持在SINGLE声明。 VB.NET

不会向我返回控制或信息。它不像我在循环中我可以控制。

Robin Tucker <编号********** @ reallyidont.com>写在

消息新闻:bv ******************* @ news.demon.co.uk ...
I know how to do that, but I''m stuck on the SINGLE statement. VB.NET
doesn''t return control or information to me. It''s not like I''m in a loop I
can control.
"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:bv*******************@news.demon.co.uk...
你想要做的是创建一个类,它自己创建一个线程来为你做
的工作。然后该线程执行委托。你的
主类上的函数可以更新进度条。

Tom Scales <到**** @ softhome.net>在消息中写道
新闻:在******************** @ comcast.com ...
What you want to do is create a class that itself creates a thread to do the work for you. This thread then executes a "delegate" function on your main class which can update the progress bar.

"Tom Scales" <to****@softhome.net> wrote in message
news:at********************@comcast.com...
好吧,我承认,我不是VB.NET专家,我还在学习,但有一个b $ b遇到了烦人的问题。我正在编写一个程序,必须搜索文件
OK, I admit, I am not a VB.NET expert and am still learning, but have run into an annoying problem. I''m writing a program that has to search the file
系统,因此处理大量的目录和文件。
system and therefore processes large numbers of directories and files.


我有

想出了DirectoryInfo(这很简单),但是当我调用DirectoryInfo.GetFiles(甚至是DirectoryInfo.GetDirectories)时,它可以花费
。一些目录中有数千个文件。

所以,我的应用程序只是坐在那里,用户认为它被锁定了。

我正在寻找为了从GetFiles函数获取回调的方法,所以
figured out DirectoryInfo (it''s pretty simple), but when I invoke
DirectoryInfo.GetFiles (or even DirectoryInfo.GetDirectories), it can take forever. Some of the directories have thousands of files in them.

So, my application just sits there and the user thinks it''s locked up.

I''m looking for a way to get a callback from the GetFiles function so




that I

实际上可以提供合理的进程条。我知道我可以快速
can actually provide a reasonable processbar. I know I could just flash


了一个

进度条等等,但我希望这些信息有意义。

有人能指点我吗在正确的方向。欢迎提供示例代码,想法和任何建议。

提前感谢您的帮助。我先搜索并搜索
progress bar or something, but I want the information to be meaningful.

Can someone point me in the right direction. Sample code, ideas, any
suggestions would be welcome.

Thanks in advance for the help. I''ve searched and searched prior to


询问

但似乎无法找到我要找的东西。

Tom
but can''t seem to find what I am looking for.

Tom




这篇关于VB.NET中的DirectoryInfo.GetFiles回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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