A directory containing files. EDIT: So, I actually did answer my own question, although the answers here were a little more clarifying.
Improve this question. Frederick The Fool I think you already gave the answer yourself :- — Jakob Christensen. This does seem an odd question. The asker already knows about the second parameter, which is a boolean called "recursive". You're basically saying "how do I do recursive? Do I set recursive to true? OK, perhaps the edit clarifies. The dir contains some files I can definitely say that this method is flaky at best. I having this exact problem where I am trying to do a recursive delete on a UNC path and even though I make sure that ALL files not directories are deleted before hand - this method is failing.
I know for a fact those folders are empty because I created them two seconds prior. No read only files situation here. Add a comment. Active Oldest Votes. Exists return; foreach var dir in baseDir. Hope it helps someone. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses.
Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Visit chat. Linked Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled. ListDirectory and WebRequestMethods. ListDirectoryDetails can vary depending on the FTP server and parsing all the alternatives can be rather tedious.
I advise that you go and look for some FTP library and look at how they are doing it. There is a good candidate on codeplex , for instance, but you may find others in the wild. Thanks very much for your valuable answer it help me alot I've googled for this question and spent so much time but couldn't get the answer.
And finally i post my question here and i've got the answer from you. Thanks Dave and Mario for your help and support. Hi Aamer,. We are very glad to hear that you got the answer here.
Thank s for your active participation in this community. If you have any difficulty in future programming, you are welcome to post here again.
Hope you are fine and working well There is a bit of problem and i am not able to solve it even tried very hard that's why i am writing here There is an unknown word starting at index 0.
Actually this error is shown in my home pc where i am using window xp and visual Ask a question. This doesn't handle a case where you have an empty directory FrumkinWY what happens with an empty directory? I don't have a machine handy to test this on now. EnumerateFiles dir. Concat Directory. EnumerateDirectories dir.
Raz Megrelidze Raz Megrelidze 2, 1 1 gold badge 23 23 silver badges 26 26 bronze badges. In Framework 2. GetFiles dir Console. WriteLine f ; foreach string d in Directory. WriteLine ex. Hernaldo Gonzalez Hernaldo Gonzalez 1, 1 1 gold badge 19 19 silver badges 30 30 bronze badges. Some excellent answers but these answers did not solve my issue. Rusty Nail Rusty Nail 2, 3 3 gold badges 28 28 silver badges 52 52 bronze badges.
Write "Exception in Helper. Sunil Purushothaman Sunil Purushothaman 7, 1 1 gold badge 18 18 silver badges 19 19 bronze badges. You're manually doing what DirectoryInfo. GetFiles will do for you out of the box - just use the overload with SearchOption. AllDirectories and it will recurse all on its own. So that's a complicated solution. GetFiles searchPattern, SearchOption.
ToList ; I do this in case in the future I need future filtering.. ToList ; I can also resort back to strings if need be. ToList ; Note that ". AddRange dir. Why the parameter files is ref? There is no need. Might allow for some sub-optimisation and avoid creating a new object unless required. So ref doesn't make anything clearer. The ref 's purpose is to change the whole files pointer even for the method's caller: it's a dangerous operation and here there is no need for that: you can just fill the List, you don't need to re-point it to another List on the heap.
RemoveAt 0 ; if searchOption. HasFlag SearchOption. GetDirectories folder ; foldersToProcess. GetFiles folder, searchPattern, SearchOption. Fidel Fidel 6, 10 10 gold badges 46 46 silver badges 68 68 bronze badges. For example, on Windows-based platforms, paths must be less than characters and file names must be less than characters.
0コメント