Search files on different PC disks [closed]

0

Good afternoon,

I have an application that scans files and automatically uploads them via FTP, but I found the inconvenience that if the owner of the computer configured the images to change their location to the disk E: \ for example I would not let the two discs, in fact I could only look at disk C, use% userprofile% and also Environment.ExpandEnvironmentVariables, which until now have not had the expected effect, I remain attentive .. thank you very much!

    
asked by Andres Galeano 30.01.2017 в 22:31
source

1 answer

3

To be able to carry out a search, you must first discover the units that are available, for this you would use:

DriveInfo.GetDrives ()

Then iterating each unit you can perform a file search by:

Directory.GetFiles Method (String, String, SearchOption)

Indicating the unit and search pattern, in addition if you define the SearchOption as AllDirectories will perform a full sweep of the whole unit, of course if there are many files it will delay.

    
answered by 30.01.2017 в 22:43