Quote:
Would you know where / how I would have to insert the code to update the UI?
As we discussed here:
Why 'part of path not found' error?[
^], enumerating files and folders in a proper way is bit difficult, especially when you use a lot of collection types that are not thread-safe. The way you grab the data in process of enumerating files and folders may also affect on time and reaction UI (hangs/freezes).
So, you have 3 possibilities:
1) not display a progress bar,
2) display a progress bar:
a) computing a cost of operation on start (like Windows OS do while copying/deleting files/folders),
b) displaying information while performing the operation (in case when a total number or size or count of stuff is unknown)
Keep in mind that there's few types of progress bars, see:
About Progress Bar Controls - Windows applications | Microsoft Docs[
^]
- Range and Current Position - represents the progress that the application has made toward completing the operation,
- Marquee style - shows activity but does not indicate what proportion of the task is complete.
I'd choose Marquee style progress bar. In case you want to display progress (by using progress bar or by refreshing UI, for example ListBox), you'll be in need to use
Control.Invoke Method (System.Windows.Forms) | Microsoft Docs[
^]. See:
How to: Make Thread-Safe Calls to Windows Forms Controls | Microsoft Docs[
^]
How to: Use a Background Thread to Search for Files | Microsoft Docs[
^]
Good luck!