I am trying to count all files and directories in specific path with a faster way,there is already a solution with c# code:
private static long SizeOf(string directory)
{
var fcounter = new CSharpTest.Net.IO.FindFile(directory, "*", true, true, true);
fcounter.RaiseOnAccessDenied = false;
long size = 0, total = 0;
fcounter.FileFound +=
(o, e) =>
{
if (!e.IsDirectory)
{
Interlocked.Increment(ref total);
size += e.Length;
}
};
Stopwatch sw = Stopwatch.StartNew();
fcounter.Find();
Console.WriteLine("Enumerated {0:n0} files totaling {1:n0} bytes in {2:n3} seconds.",
total, size, sw.Elapsed.TotalSeconds);
return size;
}
The question is,is there a same solution in maxscript?
Actually I’ve build the c# source to a dll file from here to try to work:
http://help.csharptest.net/?CSharpTest.Net.Library~CSharpTest.Net.IO.FindFile_members.html
Unfortunately I stucked,I don’t know what’s the means,does anyone can help?Thanks in advance.
DotNet.LoadAssembly @"C:\CSharp.dll"
a=dotnetclass "CSharpTest.Net.IO.FindFile"
dotNetClass:CSharpTest.Net.IO.FindFile
showmethods a
.[static]AllFilesAndFoldersIn <System.String>directory <System.Action`1[[CSharpTest.Net.IO.FindFile+FileFoundEventArgs, ClassLibrary2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]>e
.[static]AllFilesIn <System.String>directory <System.Action`1[[CSharpTest.Net.IO.FindFile+FileFoundEventArgs, ClassLibrary2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]>e
.[static]AllFoldersIn <System.String>directory <System.Action`1[[CSharpTest.Net.IO.FindFile+FileFoundEventArgs, ClassLibrary2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]>e
.[static]<System.Boolean>Equals <System.Object>objA <System.Object>objB
.[static]FilesAndFoldersIn <System.String>directory <System.Action`1[[CSharpTest.Net.IO.FindFile+FileFoundEventArgs, ClassLibrary2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]>e
.[static]FilesIn <System.String>directory <System.Action`1[[CSharpTest.Net.IO.FindFile+FileFoundEventArgs, ClassLibrary2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]>e
.[static]FoldersIn <System.String>directory <System.Action`1[[CSharpTest.Net.IO.FindFile+FileFoundEventArgs, ClassLibrary2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]>e
.[static]<System.Boolean>ReferenceEquals <System.Object>objA <System.Object>objB
a.AllFilesAndFoldersIn @"C:\" <FileFoundEventArgs> --how to use <FileFoundEventArgs>?
Refrence help
http://help.csharptest.net/CSharpTest.Net.Library~CSharpTest.Net.IO.FindFile+FileFoundEventArgs.html