<small id='sdGu2'></small><noframes id='sdGu2'>

<tfoot id='sdGu2'></tfoot>
  • <i id='sdGu2'><tr id='sdGu2'><dt id='sdGu2'><q id='sdGu2'><span id='sdGu2'><b id='sdGu2'><form id='sdGu2'><ins id='sdGu2'></ins><ul id='sdGu2'></ul><sub id='sdGu2'></sub></form><legend id='sdGu2'></legend><bdo id='sdGu2'><pre id='sdGu2'><center id='sdGu2'></center></pre></bdo></b><th id='sdGu2'></th></span></q></dt></tr></i><div id='sdGu2'><tfoot id='sdGu2'></tfoot><dl id='sdGu2'><fieldset id='sdGu2'></fieldset></dl></div>
      <bdo id='sdGu2'></bdo><ul id='sdGu2'></ul>
    <legend id='sdGu2'><style id='sdGu2'><dir id='sdGu2'><q id='sdGu2'></q></dir></style></legend>

      1. 在文件搜索期间更新进度条

        updating progress bar during a file search(在文件搜索期间更新进度条)
        <legend id='giCKa'><style id='giCKa'><dir id='giCKa'><q id='giCKa'></q></dir></style></legend>
        • <tfoot id='giCKa'></tfoot>

                <tbody id='giCKa'></tbody>

              <small id='giCKa'></small><noframes id='giCKa'>

                <bdo id='giCKa'></bdo><ul id='giCKa'></ul>

                <i id='giCKa'><tr id='giCKa'><dt id='giCKa'><q id='giCKa'><span id='giCKa'><b id='giCKa'><form id='giCKa'><ins id='giCKa'></ins><ul id='giCKa'></ul><sub id='giCKa'></sub></form><legend id='giCKa'></legend><bdo id='giCKa'><pre id='giCKa'><center id='giCKa'></center></pre></bdo></b><th id='giCKa'></th></span></q></dt></tr></i><div id='giCKa'><tfoot id='giCKa'></tfoot><dl id='giCKa'><fieldset id='giCKa'></fieldset></dl></div>
                • 本文介绍了在文件搜索期间更新进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这个 似乎有这种递归方法存在一些问题,因为我没有预先计算文件夹数量,而且对于包含许多文件的单个目录来说,这种行为会非常奇怪.

                  解决方案

                  根据您需要获得的准确度,可能有一个简单的两遍解决方案(对于网络驱动器不是最佳的,因此您可能需要在那里进行调整).

                  对于目录的前 n 级(比如 4,包括驱动器),计算子目录的数量.这通常是一个快速操作,尽管您可以将其调整为仅在存在超过 5 个子目录或类似的子目录时才递归.存储此号码.

                  当您执行真正的搜索时,请跟踪您在根目录的 n 步内完成的子目录的数量.使用此数字和存储的计数来估计完成情况.

                  以基本结构为例:

                  <代码>C:一个1一世二三23乙C

                  计数a1,忽略i和兄弟,计数2等.然后,一边搜索, 完成搜索321a等时增加条形

                  现在,这绝对不是万无一失的.可能存在竞争条件,它不是非常准确,以及各种各样的其他事情.

                  但是,对于低粒度的进度条,它足够接近以至于看起来非常准确.更重要的是,从用户体验的角度来看,使用存储的计数并将进度与之进行比较往往会阻止进度条在过程中途增长.

                  我实际上在一些代码中使用了这种技术这里.

                  初始构建(下降了 10 个级别)仍然非常快.我不记得它进行了多少测试,但是在搜索 2.5-3 百万个文件时,该栏明显准确,没有很多停顿(尽管只提前检查了 1/1000).请注意,进度条越短,显示的越准确.;)

                  This question provides a fast way to use the kernel.dll to recursively find file attributes, e.g. file names. The problem is reporting progress (such as in a Windows Forms App) is limited to which file or directory it is currently on as it has no information as to total file count upfront.

                  Though, I know in Windows 7 if you use the file explorer to search for a file, it shows a progress bar for the search:

                  So how is it they do it here? Is total file count known here ahead of time? Is it possible to mimic this kind of progress reporting in the answer from the question linked above? I'm not sure how to do it without a total file count upfront.

                  The closest question I could find was this one which seems to have some problems with this recursion method as I don't have folder count upfront, and the behavior would be very odd for a single directory of many files.

                  解决方案

                  Depending on how accurate you need to get, there may be a simple two-pass solution (not optimal for network drives, so you may need to tune there).

                  For the first n levels of directories (say 4, including drive), count the number of sub-directories. This is typically a quick operation, although you can tweak it to only recurse when more than say 5 subdirectories are present or similar. Store this number.

                  As you perform the real search, keep track of the number of subdirectories you've completed that are within n steps of the root. Use this number and the stored count to estimate completion.

                  For example, with the basic structure:

                  C:
                      a
                          1
                              i
                              ii
                              iii
                          2
                          3
                      b
                      c
                  

                  Count a, 1, ignore i and siblings, count 2, etc. Then, while searching, increase the bar when you finish searching 3, 2, 1, a, etc.

                  Now, this is absolutely not fool-proof. There may be race conditions, it's not terribly accurate, and all sorts of other things.

                  However, for a low-granularity progress bar, it's close enough that it will appear pretty accurate. More importantly from a user-experience perspective, using a stored count and comparing progress against that tends to prevent the bar from growing halfway through the process.

                  I'm actually using this technique in some code here.

                  The initial build, which goes down 10 levels, is still pretty speedy. I don't remember just how much testing went into it, but the bar is visibly accurate without many pauses when searching through 2.5-3 million files (despite only checking 1/1000th of that ahead of time). Note that the shorter your progress bar, the more accurate it will appear. ;)

                  这篇关于在文件搜索期间更新进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding and removing users from Active Directory groups in .NET(在 .NET 中的 Active Directory 组中添加和删除用户)
                  set equality in linq(在 linq 中设置相等)
                  HashSet conversion to List(HashSet 转换为 List)
                  How to set timeout for webBrowser navigate event(如何为 webBrowser 导航事件设置超时)
                  Test whether two IEnumerablelt;Tgt; have the same values with the same frequencies(测试两个IEnumerablelt;Tgt;具有相同频率的相同值)
                  How do you determine if two HashSets are equal (by value, not by reference)?(您如何确定两个 HashSet 是否相等(按值,而不是按引用)?)
                  <legend id='BCvsK'><style id='BCvsK'><dir id='BCvsK'><q id='BCvsK'></q></dir></style></legend>
                  • <bdo id='BCvsK'></bdo><ul id='BCvsK'></ul>
                    <tfoot id='BCvsK'></tfoot>

                    <small id='BCvsK'></small><noframes id='BCvsK'>

                    <i id='BCvsK'><tr id='BCvsK'><dt id='BCvsK'><q id='BCvsK'><span id='BCvsK'><b id='BCvsK'><form id='BCvsK'><ins id='BCvsK'></ins><ul id='BCvsK'></ul><sub id='BCvsK'></sub></form><legend id='BCvsK'></legend><bdo id='BCvsK'><pre id='BCvsK'><center id='BCvsK'></center></pre></bdo></b><th id='BCvsK'></th></span></q></dt></tr></i><div id='BCvsK'><tfoot id='BCvsK'></tfoot><dl id='BCvsK'><fieldset id='BCvsK'></fieldset></dl></div>

                        <tbody id='BCvsK'></tbody>