0

I'm making a simple program which finds a certain file on a drive and deletes it. I don't necessarily know how to explain it well, but I want to know if its possible for the program i'm making to be able to search all drives and delete the certain file.

For example, say the user run the program and the file is in their D: drive but someone else run the program and it is in their C: drive, how would I make the program be able to search all the drives and delete the certain file.

Theman50
  • 3
  • 2
  • Search MSDN for `FindFirstFile` and `FindNextFile`. – zdf Oct 23 '19 at 15:05
  • I would use the standard library instead [https://en.cppreference.com/w/cpp/filesystem](https://en.cppreference.com/w/cpp/filesystem) that is after you figure out what drives the user has installed. You may want to avoid network drives or anything cloud related. I am not sure of the purpose of such an application but from a user perspective it sounds very dangerous.. – drescherjm Oct 23 '19 at 15:08
  • 1
    You need a more reliable way to identify the file than just its name. – molbdnilo Oct 23 '19 at 15:12
  • Thanks, solved my problem, The program is not malicious, it is just to delete tracking files – Theman50 Oct 23 '19 at 15:31

1 Answers1

0

You may refer to this link which using std::filesystem . It will read the given path and then find the filename you may looking for.

string directory = FOUND_PATH; To delete the file then u may use filesystem::delete(directory);

Go Go Gadget 2
  • 148
  • 1
  • 2
  • 10