How many files in a directory?

  • Thread starter Thread starter tom lewton
  • Start date Start date
T

tom lewton

if the following article is to be believed:
http://msdn.microsoft.com/library/d.../en-us/fileio/base/supported_file_systems.asp
a directory can contain 66534 files. however, .net seems to give up at
32767. given that vb6 happily lets you create directories with >>32767
files,
my guess is that this is some too-clever ms whizzkid with painful lack
of
foresight who used a short instead of an int at some crucial point?
don't
suppose theres *any* chance of a solution to this one - looks like a
chunk of
unmanaged code is heading into my project....

tom
 
What function(s) are you having troubles with? the following code will
create 65000 files in a directory and then list them out. I just ran it on
Win2K, winXP and Win2003 without a problem

for(int i = 0; i < 63000; i++)
{
using(System.IO.FileStream fs = System.IO.File.Create(
String.Format(@"C:\test\{0}.tst", i)))
{
fs.WriteByte( 1);
}
}

string[] filenames = System.IO.Directory.GetFiles( @"c:\test");
foreach (string s in filenames)
{
Console.WriteLine (s);
}
 
Back
Top