search all drives for a file

Posted on 2011-10-25
Last Modified: 2012-06-27
search all available drives (cd and Usb) except C:\ untill file "Update .zip" is found
Then copy it to the c\: drive.
Question by:Jimbo1954
    LVL 33

    Expert Comment

    Here you can find code to search for the file:

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

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


    Author Comment

    Hi Thanks for the reply

    Basically what i am trying to do is update a system
    the file 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


    LVL 83

    Expert Comment

    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, "", SearchOptions.AllDirectories)

    where path will be the driveletter:\
    LVL 83

    Accepted Solution


    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now