I am trying to make a program that will search for a file on all hard disks and delete it once it is found. But I don’t know how to get started in doing this?
Also I am fairly new to coding in some aspects of C# would it be possible to get an example of how to use the code in action? If so that would be very helpful.
You can use DriveInfo.GetDrives() to get all the drives. Then Directory.GetFiles() on each drive’s RootDirectory (or any of the other Directory methods to iterate through the drives). You should probably check DriveType on each and omit any types that are readonly like CDROM and limited access network drives. Note that this can take some time so you should provide the user with ample feedback.
You should also check the file attributes to ensure you have write access. Or at least catch any exceptions that File.Delete() can throw.