Large directories... DirectoryInfo or Win32 API?
From: Mike G. (MikeG_at_discussions.microsoft.com)
Date: 09/29/04
- Next message: DotNetJunkies User: "manage multiple connections at clr level"
- Previous message: Peter Sollich [MSFT]: "RE: CLRProfiler.exe "Waiting for service to start common language runtime""
- Next in thread: Justin Rogers: "Re: Large directories... DirectoryInfo or Win32 API?"
- Reply: Justin Rogers: "Re: Large directories... DirectoryInfo or Win32 API?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 29 Sep 2004 06:51:01 -0700
Hi All,
I have a situation where I have several directories each containing hundreds
of thousands of files. I have written a program which looks at each file in a
directory, moves it to a subdirectory of a more manageable size, and updates
the file location in our database. I initially used DirectoryInfo.GetFiles()
to populate a FileInfo array to loop through. This turned out to be so slow
on these large directories that files were being added there faster than they
could be moved. It appears that when GetFiles is called it loads the entire
directory into memory before proceding to the next line.
To solve this problem I put the Win32 API functions FindFirstFile,
FindNextFile, and FindClose in a wrapper class and created a struct to hold
the FileData. This works much faster and is an acceptable solution. However,
I would like to know, is there a way of doing this natively in .NET without
directly accessing the Win32 API? I would really like to stay in the world of
managed code if possible.
Thanks,
Mike G.
- Next message: DotNetJunkies User: "manage multiple connections at clr level"
- Previous message: Peter Sollich [MSFT]: "RE: CLRProfiler.exe "Waiting for service to start common language runtime""
- Next in thread: Justin Rogers: "Re: Large directories... DirectoryInfo or Win32 API?"
- Reply: Justin Rogers: "Re: Large directories... DirectoryInfo or Win32 API?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|