I am working on a TypeScript web application that has a specific folder structure. Here is how it looks:
- assets
|- a.png
|- b.png
|- c.png
|- d.png
|- ...
- app.ts
My question is: In the app.ts
file, how can I programmatically list all the files within the assets
folder?
I attempted the code below, but unfortunately, it did not yield the results I was hoping for. Additionally, I realized that using fs
to access the user's file system might not be the correct approach for my project.
const fs = require('fs');
const assets_folder = './assets/';
fs.readdirSync(assets_folder).forEach((file) => {
console.log(file);
});