0

To give some context, I am letting the user drag files of his choice (as many as he'd like) to a folder that my program reads. How can my program find those files and reference them?

I am only looking for a function that does like following: getUnknownFile(int index) to return the file name or destination.

-Thanks

  • What have you done so far? Please provide us a minimal example – NutCracker Jan 17 '20 at 08:30
  • 3
    Please pick one language, as solutions could be very different in different programming languages (C and C++ are two very different languages). – Some programmer dude Jan 17 '20 at 08:32
  • C++17 provides a very new [Filesystem library](https://en.cppreference.com/w/cpp/experimental/fs) to inspect directories. Prior to this, you are bound to platform dependent (or third party) solutions. FYI: [SO: How can I get the list of files in a directory using C or C++?](https://stackoverflow.com/q/612097/7478597) – Scheff's Cat Jan 17 '20 at 08:37
  • 1
    Since the order of the files may change while looping, you shuldn't use a numeric index as iterator. – HAL9000 Jan 17 '20 at 08:37
  • I don't know any operating system which guarantees that the order of files if you get the list multiple times, which means a single index could give you different files at different times. So in short don't use indexes. – Some programmer dude Jan 17 '20 at 08:46
  • I initially was going to use C since it seems more simple but I think I'm going to try the idea of using C++17's filesystem libary. Thx all – Adam Palmkvist Jan 17 '20 at 09:19

0 Answers0