473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Retreiving file list from a directory

Is there a built in way in .net to retrieve all the files in a
directory one at a time? I have to process a bunch of files serially
and there can be more than 100K files in the dir. I am trying to avoid
FileInfo[] or System.IO.Directory.GetCurrentDirectory() as I don't
want all the info loaded into memory at once.

Previously I would just use FindFirst and Findnext

Thanks
Wayne

Nov 17 '05 #1
3 1356
Wayne,

In this case, you would want to call FindFirstFileEx through the
P/Invoke layer. It will return a handle which represents the search. Then,
you would process your files one after another in a loop, calling
FindNextFile to get the next file information.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"ThisBytes5" <Th********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Is there a built in way in .net to retrieve all the files in a
directory one at a time? I have to process a bunch of files serially
and there can be more than 100K files in the dir. I am trying to avoid
FileInfo[] or System.IO.Directory.GetCurrentDirectory() as I don't
want all the info loaded into memory at once.

Previously I would just use FindFirst and Findnext

Thanks
Wayne

Nov 17 '05 #2
When done, is a Close of some sort
needed?
Roger
In this case, you would want to call FindFirstFileEx through the
P/Invoke layer. It will return a handle which represents the search. Then, you would process your files one after another in a loop, calling
FindNextFile to get the next file information.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"ThisBytes5" <Th********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Is there a built in way in .net to retrieve all the files in a
directory one at a time? I have to process a bunch of files serially
and there can be more than 100K files in the dir. I am trying to avoid
FileInfo[] or System.IO.Directory.GetCurrentDirectory() as I don't
want all the info loaded into memory at once.

Previously I would just use FindFirst and Findnext

Thanks
Wayne


Nov 17 '05 #3
Roger,

You will have to call the FindClose function.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Roger" <rj**@netzero.com> wrote in message
news:ek*************@TK2MSFTNGP09.phx.gbl...
When done, is a Close of some sort
needed?
Roger
In this case, you would want to call FindFirstFileEx through the
P/Invoke layer. It will return a handle which represents the search.

Then,
you would process your files one after another in a loop, calling
FindNextFile to get the next file information.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"ThisBytes5" <Th********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
> Is there a built in way in .net to retrieve all the files in a
> directory one at a time? I have to process a bunch of files serially
> and there can be more than 100K files in the dir. I am trying to avoid
> FileInfo[] or System.IO.Directory.GetCurrentDirectory() as I don't
> want all the info loaded into memory at once.
>
> Previously I would just use FindFirst and Findnext
>
> Thanks
> Wayne
>



Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Kim Jensen | last post by:
I'd like to make a directory listing where instead of the entire filename I need it to show the filename minus the extention and get the value of charname= in the file itself. I've been told...
2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
3
by: Greg Yasko | last post by:
Hi. Does anyone know if there's an equivalent of Perl's file::find module in Python? It traverses a directory. I've googled extensively and checked this newsgroup and can't find anything like it...
5
by: Dhans | last post by:
Framework version : 1.1 For a given directory (which may have subdirectories), I need to identify the number of text files (*.txt). For this I have tried recursive method to search files, it...
2
by: Tiger | last post by:
I try to write a struct into a brut file but I can't write all var in this struct when I try to add user I have that : > testmachine:/usr/share/my_passwd# ./my_passwd -a users.db > Ajout d'une...
29
by: jaysherby | last post by:
I'm new at Python and I need a little advice. Part of the script I'm trying to write needs to be aware of all the files of a certain extension in the script's path and all sub-directories. Can...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
4
by: tasahmed | last post by:
Hello Friends, I wrote a function which scans the current working directory and lists out details such as directory/file owner, permission etc. The output of this script can be viewing in the...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.