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

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

Directory.GetFiles: how to get only filename, not full path? [duplicate]

You can use System.IO.Path.GetFileName to do this. E.g., string[] files = Directory.GetFiles(dir); foreach(string file in files) Console.WriteLine(Path.GetFileName(file)); While you could use FileInfo, it is much more heavyweight than the approach you are already using (just retrieving file paths). So I would suggest you stick with GetFiles unless you need the additional functionality of the FileInfo … 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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)