How to include a file dynamically?

I have many external .h files in a folder. I'd like to include them dynamically, I mean without having to click on Sketch and then on Add File in the Arduino app to do this.

But I didn't find any way to do this dynamically without getting an error. Any help highly appreciated!

Just copy them to the sketch's directory I think, restart the Arduino software...

Funny! I thought I added them all by hand (I took a break a few months ago). But now that you tell me I realize I did not, cause now that I tried with new files, it works. Thank you!

A file was .txt, this confused me. Changed to .h.

What does not work is having them in a folder in the Sketch folder, like "myFolder/myFile.h". No matter how I declare my path. It would be awesome if I could leave all the files I want to include in different folders.

In my files I have arrays... I mean my files are not Librairies.

I forgot to mention that I tried

include "myFolder/myFile.h"

and it did no work.

myring: I forgot to mention that I tried

include "myFolder/myFile.h"

and it did no work.

As far as I know, a sketch can only have files in the root of the sketch folder. Anything else is not seen.

The IDE team is working on fixing this (along with the requirement to add libraries to a sketch that other libs use).

Also no need to restart the IDE when adding files, just re-open the sketch using the menu and the changes become visible.

Thank you very much for all infos and advices!

If you have a .h and a .cpp/.c then it is a lib and you should deal with it as such.