vb.net - Fast way to enumerate all files including sub-folders -


Is there a faster way to calculate all the files in a directory through a directory and sub-folders? The way? This is what I currently have:

  All files in the public share () string AllFiles = Directory.GetFiles (, "*. *", SearchOption .All Directories)  

Thanks! JFV

Edit: I am enumerating these files from a server location, I do not know whether it will change the perspective of this question or not. Thanks for all the input so far!

short answer:

If this code is functionally correct for your project And you have not proven it to be a problem with a professor, so do not change it, continue to work properly using the correct solution until you slow it down.

Long answer:

The code is particularly fast or slow depending on the factors lot of which many of you are running on specific Depending on the machine (speed of the hard drive, for example). Looking at the code in which the file system is included and nothing else, it is difficult to say that "faster than xy" is with any certainty

In this case, I actually only have one thing I can comment. The return type of this method is an array of fileinfo values. Array needs closest memory and a very large array can cause fragmentation issues in your heap. If you have a extremely large directory that you are reading then it may be due to fragmentation and indirect performance issues.

If this becomes a problem, then you can PInvoke in FindFirstFile / FindNextFile and get them at once. The result will be functionally slow in CPU cycles, but there will be less memory pressure.

But I should stress that you should decide that before you can ok


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -