Link to home
Start Free TrialLog in
Avatar of Jimbo1954
Jimbo1954

asked on

search all drives for a file

search all available drives (cd and Usb) except C:\ untill file "Update .zip" is found
Then copy it to the c\: drive.
Jimbo
Avatar of jppinto
jppinto
Flag of Portugal image

Here you can find code to search for the file:

https://www.experts-exchange.com/questions/21679731/Searching-for-files-across-all-drives.html

Then you can just copy it using a command like this:

File.Copy(strPath &"\Update.zip", "C:\Update.zip")

jppinto
Avatar of Jimbo1954
Jimbo1954

ASKER

Hi Thanks for the reply

Basically what i am trying to do is update a system
the file update.zip will always be in the root usually on a usb pen drive but could also be on cd

the problem is i dont know what disc drives are present on the machines to be updated or if the pen drive has previously be allocated a drive letter (eg X or z)

i dont need to search drive c because the update will always be either usb drive or cd
and it will always be placed in the root of that drive.

once the file is found i want it to be copied to the c:\ drive

hope this explains it better

Jimbo

Avatar of Nasir Razzaq
Use the My.Computer.FileSystem.Drives collection to get a list of all drives in the system. Then use the

Dim Files as String() = Directory.GetFiles(path, "update.zip", SearchOptions.AllDirectories)

where path will be the driveletter:\
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks