Questions tagged [getfiles]

266 questions
104
votes
7 answers

GetFiles with multiple extensions

Possible Duplicate: Can you call Directory.GetFiles() with multiple filters? How do you filter on more than one extension? I've tried: FileInfo[] Files = dinfo.GetFiles("*.jpg;*.tiff;*.bmp"); FileInfo[] Files =…
rd42
  • 3,584
  • 15
  • 56
  • 68
94
votes
4 answers

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

Possible Duplicate: How to get only filenames within a directory using c#? Using C#, I want to get the list of files in a folder. My goal: ["file1.txt", "file2.txt"] So I wrote this: string[] files = Directory.GetFiles(dir); Unfortunately, I get…
Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373
81
votes
9 answers

Ignore folders/files when Directory.GetFiles() is denied access

I am trying to display a list of all files found in the selected directory (and optionally any subdirectories). The problem I am having is that when the GetFiles() method comes across a folder that it cannot access, it throws an exception and the…
Rowan
  • 2,384
  • 2
  • 21
  • 22
75
votes
24 answers

Get all files recursively in directories NodejS

I have a little problem with my function. I would like to get all files in many directories. Currently, I can retrieve the files in the file passed in parameters. I would like to retrieve the html files of each folder in the folder passed as a…
user6285277
75
votes
3 answers

Directory.GetFiles of certain extension

Is there a way to simplify this linq expression, or is there a better way of doing this? Directory.GetFiles(dir, "*.*", SearchOption.AllDirectories) .Where(s => s.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) || …
XSL
  • 2,965
  • 7
  • 38
  • 61
68
votes
6 answers

Retrieving files from directory that contains large amount of files

I have directory that contains nearly 14,000,000 audio samples in *.wav format. All plain storage, no subdirectories. I want to loop through the files, but when I use DirectoryInfo.GetFiles() on that folder the whole application freezes for…
eddyuk
  • 4,110
  • 5
  • 37
  • 65
53
votes
6 answers

Sorting the result of Directory.GetFiles in C#

I have this code to list all the files in a directory. class GetTypesProfiler { static List Test() { List dataList = new List(); string folder = @"DIRECTORY"; …
prosseek
  • 182,215
  • 215
  • 566
  • 871
26
votes
6 answers

UnauthorizedAccessException cannot resolve Directory.GetFiles failure

Directory.GetFiles method fails on the first encounter with a folder it has no access rights to. The method throws an UnauthorizedAccessException (which can be caught) but by the time this is done, the method has already failed/terminated. The code…
Ric
  • 683
  • 2
  • 11
  • 19
19
votes
3 answers

Directory.GetFiles finds nonexisting files

I just stumbled upon an undocumented behavior of the GetFiles methods in System.IO.Directory. Whenever the searchPattern parameter passed to the method contains a reserved Windows device name, such as "nul.*" or "aux.bmp", the method returns an…
GOTO 0
  • 42,323
  • 22
  • 125
  • 158
16
votes
4 answers

C# get file paths of just files with no extensions

I am wanting to get a string array of paths of files that do not have extensions. They are binary files with no extensions if that helps. For example, I am loading a group of file paths out of a folder /test/ I want just the path and filenames that…
RKlenka
  • 163
  • 1
  • 7
15
votes
5 answers

How to get file using PHP native functions and Android

I did a function in private section of my website, to get and display some file of a repository. Below is the function I did : function getFilesChantier($devis, $cp) { // Si dossier cp n'existe pas on le créé if…
Stanislas Piotrowski
  • 2,595
  • 10
  • 40
  • 59
13
votes
4 answers

How can I make GetFiles() exclude files with extensions that start with the search extension?

I am using the following line to return specific files... FileInfo file in nodeDirInfo.GetFiles("*.sbs", option) But there are other files in the directory with the extension .sbsar, and it is getting them, too. How can I differentiate between .sbs…
topofsteel
  • 1,267
  • 6
  • 16
  • 25
11
votes
2 answers

Have Directory.GetFiles return one file at a time? (.NET)

I have a folder with far too many files in, and I want to go through each file one by one. The problem is that Directory.GetFiles returns a completed array, and this takes too long. I would rather have an object I would point to a folder, then call…
billpg
  • 3,195
  • 3
  • 30
  • 57
10
votes
6 answers

C# return full path with GetFiles

Use this code for search files in directory: FileInfo[] files = null; string path = some_path; DirectoryInfo folder = new DirectoryInfo(path); files = folder.GetFiles("*.*", SearchOption.AllDirectories); This return only filename and extension…
user1775334
  • 161
  • 1
  • 1
  • 7
8
votes
8 answers

Exact file extension match with GetFiles()?

I'd like to retrieve a list of files whose extensions match a specified string exactly. DirectoryInfo di = new DirectoryInfo(someValidPath); List myFiles = new List(); foreach (FileInfo fi in di.GetFiles("*.txt")) { …
John
  • 15,990
  • 10
  • 70
  • 110
1
2 3
17 18