Questions tagged [getfiles]

266 questions
8
votes
2 answers

How can Directory.Getfiles() multi searchpattern filters c#

Possible Duplicate: Can you call Directory.GetFiles() with multiple filters? I have a string array: string[] pattern={"*.jpg","*.txt","*.asp","*.css","*.cs",.....}; this string pattern string[] dizin =…
bmurat
  • 81
  • 1
  • 1
  • 8
7
votes
4 answers

Weird functionality in .NET's Directory.GetFiles() when search pattern contains 3 chars for extension

I recently bumped into a weird functionality from Microsoft: Let's assume our folder c:\tmp123 contains 3 files - 1.txt 2.txtx 3.txtxt a) Invocation of Directory.GetFiles(@"C:\tmp123", "*.txt") yields in 3 returned items. b) Invocation of…
user1140419
  • 111
  • 1
  • 6
7
votes
6 answers

Using C#, how to know whether a folder is located on a network or not

Using C#, I would like my application to return whether a folder (with an already known path) is located in a network or in my computer. How can I do that?
MyrR
  • 71
  • 1
  • 2
7
votes
3 answers

How can I access the "Documents and Settings" folder?

I'm using C# .NET 4 with VS 2010. When Iterating over some paths, I'm running this line: files = Directory.GetFiles(path, searchPattern); I get an exception when the path is the documents and settings folder. How can I access it? And no, I don't…
CodeMonkey
  • 11,196
  • 30
  • 112
  • 203
6
votes
2 answers

Directory.GetFiles: Show only files starting with a numeric value

How can i get the Directory.GetFiles to only show me files starting with a numeric value (eg. 1abc.pdf); Directory.GetFiles(@"C:/mydir", "0-9*.pdf")
brother
  • 7,651
  • 9
  • 34
  • 58
6
votes
1 answer

React native, import and read local xml file

I'm new to React Native framework. I'm trying to use it for make a cross-platform mobile app. I want to open and read a local XML file, present in my app folder, but I can't work out how to do this. My biggest problem at the moment is how to assign…
6
votes
1 answer

In F#: How do I obtain a list of the filenames in a directory; expected unit have string

I'm just starting with F# so I thought I would try some simple tasks. This lists the full paths to the xml files in a directory: System.IO.Directory.GetFiles("c:\\tmp", "*.xml") |> Array.iter (printfn "%s") But I want only the file names so I…
Kevin Whitefoot
  • 414
  • 3
  • 15
6
votes
3 answers

What happens with Directory.EnumerateFiles if directory content changes during iteration?

I've read discussions about difference between Directory.EnumerateFiles and Directory.GetFiles. I understand that internally they both use System.IO.FileSystemEnumerableFactory.CreateFileNameIterator() The difference is that EnumerateFiles might use…
Harald Coppoolse
  • 28,834
  • 7
  • 67
  • 116
6
votes
1 answer

How can I release locks on files/folders after using Directory.GetFiles?

I'm using IO.Directory.GetFiles to search for files in a folder. After the searching is done, I can't use files in this folder until my application is closed. I haven't found any Dispose functions in DirectoryInfo class, so my question is: How can I…
user3561694
  • 105
  • 1
  • 9
5
votes
5 answers

Listing Folders in a Directory using asp.net and C#

.aspx file: <%@ Import Namespace="System.IO" %> Explorer
.CS file: using System; …
Naresh
  • 657
  • 3
  • 16
  • 35
5
votes
1 answer

How to get all files from folder and subfolder in magento 2

I made a module for uploading images in frontend. Magento 2 saves files in a special way. For example: uploading file - file.png, path to file - pub/media/[module_folder]/f/i/file.png. How to get all files from [module_folder]?
Alex
  • 71
  • 1
  • 4
5
votes
2 answers

Get directory where executed code is located

I know that in the same directory where my code is being executed some files are located. I need to find them and pass to another method: MyLib.dll Target1.dll Target2.dll Foo(new[] { "..\\..\\Target1.dll", "..\\..\\Target2.dll" }); So I call…
abatishchev
  • 98,240
  • 88
  • 296
  • 433
4
votes
3 answers

How to use DirectoryInfo.GetFiles and have it stop after finding the first match?

Need to search the directory/sub-directories to find a file, would prefer it to stop once it has found one. Is this a feature built into DirectoryInfo.GetFiles that I am missing, or should I be using something else (self-implemented recursive…
RiddlerDev
  • 7,370
  • 5
  • 46
  • 62
4
votes
1 answer

trying to use Directory .EnumerateFiles("*.jpg", SearchOption.AllDirectories);

So i'm using Directory.GetFiles(folder, "*.jpg", SearchOption.AllDirectories). When i try it on the c:\ drive in windows 7, since windows 7 still had c:\documents and settings (for legacy systems like xp), it's a protected folder. It's only…
darthwillard
  • 809
  • 2
  • 14
  • 28
4
votes
1 answer

Is there a way to stop a Directory.GetFiles search

I'm using Directory.GetFiles() to search files in a multi-folder directory and some of these folders are too big so the search could take up to 60 seconds. In the code below a search starts a second after the user stops typing, this works great when…
fs_tigre
  • 10,650
  • 13
  • 73
  • 146
1
2
3
17 18