Hello community,I'm working on an application which give end users a way to display folders & files on a bunch of network resources not accessible through file explorer and later on, which will allow them to upload files on specific folders.I'm working on the back end stuff and even if I do made some progresses I wanted to know if I was doing it in the right way.Here is the way I get the list of files```javascript const fs = require('fs');folder = 'file://myserver/e$/folder1/subfolder1'; urlfolder = new URL(folder) let files = fs.readdirSync(urlfolder); files.forEach(file => { let filefullpath = folder+ '/' + file; try { let isdir = fs.readdirSync(new URL(filefullpath)); console.log( file + ' is directory'); } catch (error) { console.log(file + ' is a file'); } }); ```If found no better way to test if each entry is a folder or a file as I was not able to get the stat working against an UNC path. If you confirm I'm on track and there no other way to do this, I'll transform this code in a recursive function.Thanks for your help !Bob
Submitted March 01, 2020 at 04:08PM by BobMilli
No comments:
Post a Comment