asked on
C# .Net Framework version 4.7.
Directory.GetFiles is skipping files. A lot of them.
File Explorer shows 635,286 while the count of Directory.GetFiles is 603,097.
Here is my code that is currently using EnumerateFiles but the results are the same as GetFiles.
public void FindMyFolders()
{
conn = new SqlConnection("Persist Security Info=False;Integrated Security=true;Initial Catalog=NCTRIAL; Server=PROLAWPRIME");
conn.Open();
const string path = @"\\prolawprime\prolawfiles\Documents\";
IEnumerable<string> mainpath;
Console.WriteLine("Gathering Data...");
mainpath = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories);
Console.WriteLine("Number of files: " + mainpath.Count().ToString());
Console.ReadLine();
Any ideas on why GetFiles would skip files?
I have tried unchecking Prefer 32-bit just in case. Note that some files may have very long path names in excess of 383 characters.
Note that I receive no errors when this is done and am able to loop through the array (or IEnumerable) and place into a database.
Thank you for your help.
JamesNT
ASKER
ASKER
ASKER
ASKER
Use the \\?\C:\Verrrrrrrrrrrry long path syntax as described here.
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.
TRUSTED BY
you may have to add manifest in visual studio
Open in new window