Develop the "Search for large files" tool in WPF of Jin xuliang software tool series

Source: Internet
Author: User
Tags visual studio 2010

"Software Tool Development Series"


Develop the "Search for large files" tool for WPF


For various reasons and purposes, I have successively written some small utility programs. I plan to publish them if I have time. First, I hope these gadgets can solve some practical problems, the second is to provide some "visible" Examples for many of my students and software developers for reference. I try to publish the sample source code along with the article, but for various reasons, some programs may only provide the installer or runable version, some programs can only display the interface, development ideas and technical points through the article, and the program itself is not publicly published.

Anyone who provides the source code can freely modify and use it.

This is the first article in this series. I hope you will like this little tool.

Jin xuliang


========================================================== ====================================


The disk space is insufficient. You need to remove unnecessary files, but I don't know how many files to delete to free up enough space. Sometimes, it is not enough to delete a bunch of small files.


Instead of deleting a pile of "small files", it is better to focus only on "large files ". To this end, you can write a small tool to search for all files larger than the specified size in the specified folder.

Technology Selection:

This program is developed using WPF Based on. NET 4.0. Project format: Visual Studio 2012, development language: C #

If Visual Studio 2010 is used, create a self-built WPF project and move the source code to compile the project.

Running environment:

Install. NET Framework 4.0 on a Windows computer. Windows 7 64-bit flagship edition is successfully tested.

Interface Design:

According to the functions that people need most after finding files, the design program interface is as follows:


The file list in the middle uses the DataGrid control, while others are simple WPF controls. The overall layout uses the dockpanel, which supports dynamic adjustment of the interface size.

Key Points of programming technology:

(1) The search function is completed using Plinq provided by. Net 4.0, and the model cancellation operation is canceled using a thread.

(2) because the search is completed in an independent thread, the work of updating the interface uses the dispatcher object to push the UI update code to the UI thread for execution.

(3) Some system folders cannot read files due to permission issues during file search. Therefore, you must properly handle the unauthorizedaccessexception exception.

(4) After finding the file, you need to display the file name in the list. Therefore, a foundfile class is designed to encapsulate the information. Display uses the powerful data binding mechanism of WPF. Therefore, let the foundfile class implement the inotifypropertychanged interface, put the foundfile object in the observablecollection generic collection, and bind it to the DataGrid. It should be noted that the WPF Data Binding supports cross-thread update of the DataGrid, which greatly reduces the amount of code writing.

(5) the file size is byte. Therefore, write a numberconverter class to convert it to common K, M, G, etc, design the WPF data binding mechanism to use it for Numerical Conversion (see the binding expression of the DataGrid for details)


Although this tool is small, many technologies are used. Because existing technologies and components are fully applied, for example, the DataGrid itself has very powerful functions, making the entire program code a small amount, and the interface friendliness is also good. If Java is used for development, it requires a lot of work. The most important thing is that the performance of Java Desktop applications is terrible. If C ++ is used to develop an unmanaged version, the problem is that the development efficiency is too low, even such a small program, it may take a lot of time (maybe a week) to implement all functions of C #, but C ++ has a benefit, all windows instances can run without installation.. net.

To learn more about the Plinq technology used in this program, refer to my article titled. Net 4.0 object-oriented programming.

Visit the csdn download channel to obtain the project source code and EXE file:

Click this link to download the findallhudgefiles source code for the WPF development "find large files" tool.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.