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

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

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