Get all files recursively in directories NodejS

It looks like the glob npm package would help you. Here is an example of how to use it: File hierarchy: test ├── one.html └── test-nested └── two.html JS code: const glob = require(“glob”); var getDirectories = function (src, callback) { glob(src + ‘/**/*’, callback); }; getDirectories(‘test’, function (err, res) { if (err) { console.log(‘Error’, … Read more

How to get selected xls file path from uri for SDK 17 or below for android?

use my FileSelector : how to use : new FileSelector(this, new String[]{FileSelector.XLS, FileSelector.XLSX}).selectFile(new FileSelector.OnSelectListener() { @Override public void onSelect(String path) { G.toast(path); } }); new FileSelector(this, new String[]{“.jpg”, “.jpeg”}).selectFile(new FileSelector.OnSelectListener() { @Override public void onSelect(String path) { G.toast(path); } }); source code : (create class ‘FileSelector’ and copy/paste) import android.app.Activity; import android.app.Dialog; import android.graphics.Typeface; import … Read more

Retrieving files from directory that contains large amount of files

Have you tried EnumerateFiles method of DirectoryInfo class? As MSDN Says The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of FileInfo objects before the whole collection is returned; when you use GetFiles, you must wait for the whole array of FileInfo objects to be returned … Read more

Directory.GetFiles of certain extension

If you would like to do your filtering in LINQ, you can do it like this: var ext = new List<string> { “jpg”, “gif”, “png” }; var myFiles = Directory .EnumerateFiles(dir, “*.*”, SearchOption.AllDirectories) .Where(s => ext.Contains(Path.GetExtension(s).TrimStart(“.”).ToLowerInvariant())); Now ext contains a list of allowed extensions; you can add or remove items from it as necessary for … Read more

GetFiles with multiple extensions [duplicate]

Why not create an extension method? That’s more readable. public static IEnumerable<FileInfo> GetFilesByExtensions(this DirectoryInfo dir, params string[] extensions) { if (extensions == null) throw new ArgumentNullException(“extensions”); IEnumerable<FileInfo> files = Enumerable.Empty<FileInfo>(); foreach(string ext in extensions) { files = files.Concat(dir.GetFiles(ext)); } return files; } EDIT: a more efficient version: public static IEnumerable<FileInfo> GetFilesByExtensions(this DirectoryInfo dir, params string[] … Read more

UnauthorizedAccessException cannot resolve Directory.GetFiles failure [duplicate]

In order to gain control on the level that you want, you should probably probe one directory at a time, instead of a whole tree. The following method populates the given IList<string> with all files found in the directory tree, except those where the user doesn’t have access: // using System.Linq private static void AddFiles(string … Read more